package schema

import (
	"context"
	"testing"

	"github.com/spaceuptech/space-cloud/gateway/config"
	"github.com/spaceuptech/space-cloud/gateway/managers/admin"
	"github.com/spaceuptech/space-cloud/gateway/model"
	"github.com/spaceuptech/space-cloud/gateway/modules/crud"
	. "github.com/spaceuptech/space-cloud/gateway/modules/schema/helpers"
)

func TestSchema_generateCreationQueries(t *testing.T) {
	type fields struct {
		SchemaDoc model.Type
		crud      model.CrudSchemaInterface
		project   string
		config    config.DatabaseSchemas
	}
	type args struct {
		dbAlias       string
		tableName     string
		project       string
		parsedSchema  model.Type
		currentSchema model.Collection
	}
	type testGenerateCreationQueries struct {
		name    string
		fields  fields
		args    args
		want    []string
		isSort  bool
		wantErr bool
	}

	adminMan := &admin.Manager{}
	crudPostgres := crud.Init()
	crudPostgres.SetAdminManager(adminMan)
	err := crudPostgres.SetConfig("test", config.DatabaseConfigs{config.GenerateResourceID("chicago", "myproject", config.ResourceDatabaseConfig, "postgres"): &config.DatabaseConfig{DbAlias: "postgres", Type: "sql-postgres", Enabled: false}})
	if err != nil {
		t.Fatal("unable to initialize postgres", err)
	}

	crudMySQL := crud.Init()
	crudMySQL.SetAdminManager(adminMan)
	err = crudMySQL.SetConfig("test", config.DatabaseConfigs{config.GenerateResourceID("chicago", "myproject", config.ResourceDatabaseConfig, "mysql"): &config.DatabaseConfig{DbAlias: "mysql", Type: "sql-mysql", Enabled: false}})
	if err != nil {
		t.Fatal("unable to initialize my sql", err)

	}

	crudSQLServer := crud.Init()
	crudSQLServer.SetAdminManager(adminMan)
	err = crudSQLServer.SetConfig("test", config.DatabaseConfigs{config.GenerateResourceID("chicago", "myproject", config.ResourceDatabaseConfig, "sqlserver"): &config.DatabaseConfig{DbAlias: "sqlserver", Type: "sql-sqlserver", Enabled: false}})
	if err != nil {
		t.Fatal("unable to initialize sql server", err)
	}

	var noQueriesGeneratedTestCases = []testGenerateCreationQueries{
		// Mysql
		{
			name: "Mysql no queries generated when both schemas have 2 fields with type Float",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", TypeIDSize: model.DefaultCharacterSize, Kind: model.TypeFloat}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeFloat, TypeIDSize: model.DefaultCharacterSize}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "Mysql no queries generated when both schemas have 2 fields with type Decimal",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", TypeIDSize: model.DefaultCharacterSize, Kind: model.TypeDecimal, Args: &model.FieldArgs{Precision: 10, Scale: 5}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeDecimal, TypeIDSize: model.DefaultCharacterSize, Args: &model.FieldArgs{Precision: 10, Scale: 5}}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "Mysql no queries generated when both schemas have 2 fields with type ID",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", TypeIDSize: model.DefaultCharacterSize, Kind: model.TypeID}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "Mysql no queries generated when both schemas have 2 fields 1 with type ID & other having type String",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeString}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeString}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "Mysql no queries generated when both schemas have 2 fields 1 with type ID & other having type Integer",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeInteger}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeInteger}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "Mysql no queries generated when both schemas have 2 fields 1 with type ID & other having type Float",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeFloat, Args: &model.FieldArgs{Precision: model.DefaultPrecision, Scale: model.DefaultScale}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeFloat, Args: &model.FieldArgs{Precision: model.DefaultPrecision, Scale: model.DefaultScale}}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "Mysql no queries generated when both schemas have 2 fields 1 with type ID & other having type DateTime",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeDateTime, Args: &model.FieldArgs{Scale: model.DefaultScale}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeDateTime, Args: &model.FieldArgs{Scale: model.DefaultScale}}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "Mysql no queries generated when both schemas have 2 fields 1 with type ID & other having type JSON",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeJSON}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeJSON}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "Mysql no queries generated when both schemas have 2 fields with type ID not null",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsFieldTypeRequired: true, TypeIDSize: model.DefaultCharacterSize, Kind: model.TypeID}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsFieldTypeRequired: true, Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "Mysql no queries generated when both schemas have 2 fields 1 with type ID & other having type String not null",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsFieldTypeRequired: true, Kind: model.TypeString}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsFieldTypeRequired: true, Kind: model.TypeString}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "Mysql no queries generated when both schemas have 2 fields 1 with type ID & other having type Integer not null",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsFieldTypeRequired: true, Kind: model.TypeInteger}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsFieldTypeRequired: true, Kind: model.TypeInteger}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "Mysql no queries generated when both schemas have 2 fields 1 with type ID & other having type Float not null",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsFieldTypeRequired: true, Kind: model.TypeFloat, Args: &model.FieldArgs{Precision: model.DefaultPrecision, Scale: model.DefaultScale}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsFieldTypeRequired: true, Kind: model.TypeFloat, Args: &model.FieldArgs{Precision: model.DefaultPrecision, Scale: model.DefaultScale}}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "Mysql no queries generated when both schemas have 2 fields 1 with type ID & other having type DateTime not null",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsFieldTypeRequired: true, Kind: model.TypeDateTime, Args: &model.FieldArgs{Precision: model.DefaultPrecision}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsFieldTypeRequired: true, Kind: model.TypeDateTime, Args: &model.FieldArgs{Precision: model.DefaultPrecision}}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "Mysql no queries generated when both schemas have 2 fields 1 with type ID & other having type JSON not null",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsFieldTypeRequired: true, Kind: model.TypeJSON}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsFieldTypeRequired: true, Kind: model.TypeJSON}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "Mysql no queries generated when both schemas have 2 fields with type ID with default value",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsDefault: true, Default: "INDIA", TypeIDSize: model.DefaultCharacterSize, Kind: model.TypeID}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsDefault: true, Default: "INDIA", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "Mysql no queries generated when both schemas have 2 fields 1 with type ID & other having type String with default value",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsDefault: true, Default: "INDIA", Kind: model.TypeString}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsDefault: true, Default: "INDIA", Kind: model.TypeString}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "Mysql no queries generated when both schemas have 2 fields 1 with type ID & other having type Integer with default value",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsDefault: true, Default: "100", Kind: model.TypeInteger}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsDefault: true, Default: "100", Kind: model.TypeInteger}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "Mysql no queries generated when both schemas have 2 fields 1 with type ID & other having type Float with default value",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsDefault: true, Default: "9.8", Kind: model.TypeFloat, Args: &model.FieldArgs{Precision: model.DefaultPrecision, Scale: model.DefaultScale}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsDefault: true, Default: "9.8", Kind: model.TypeFloat, Args: &model.FieldArgs{Precision: model.DefaultPrecision, Scale: model.DefaultScale}}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "Mysql no queries generated when both schemas have 2 fields 1 with type ID & other having type DateTime with default value",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsDefault: true, Default: "2020-05-30T00:42:05+00:00", Kind: model.TypeDateTime, Args: &model.FieldArgs{Precision: model.DefaultPrecision}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsDefault: true, Default: "2020-05-30T00:42:05+00:00", Kind: model.TypeDateTime, Args: &model.FieldArgs{Precision: model.DefaultPrecision}}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "Mysql no queries generated when both schemas have 2 fields 1 with type ID & other having type JSON with default value",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsDefault: true, Default: `{"id":"zerfvnex","name":"john"}`, Kind: model.TypeJSON}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsDefault: true, Default: `{"id":"zerfvnex","name":"john"}`, Kind: model.TypeJSON}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "Mysql no queries generated when both schemas have only 1 primary key",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "Mysql no queries generated when both schemas have 2 fields 1 with type ID & other having type ID with foreign key",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table2": model.Fields{"id": &model.FieldType{FieldName: "id", IsFieldTypeRequired: true, IsPrimary: true}}, "table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsForeign: true, JointTable: &model.TableProperties{Table: "table2", To: "id", ConstraintName: GetConstraintName("table2", "id"), OnDelete: "NO ACTION"}, TypeIDSize: model.DefaultCharacterSize, Kind: model.TypeID}}}},
				currentSchema: model.Collection{"table2": model.Fields{"id": &model.FieldType{FieldName: "id", IsFieldTypeRequired: true, IsPrimary: true}}, "table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsForeign: true, JointTable: &model.TableProperties{Table: "table2", To: "id", ConstraintName: GetConstraintName("table2", "id"), OnDelete: "NO ACTION"}, Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "Mysql no queries generated when both schemas have 2 fields 1 with type ID & other having type ID with foreign key on delete CASCADE",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table2": model.Fields{"id": &model.FieldType{FieldName: "id", IsFieldTypeRequired: true, IsPrimary: true}}, "table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsForeign: true, JointTable: &model.TableProperties{Table: "table2", To: "id", ConstraintName: GetConstraintName("table2", "id"), OnDelete: "CASCADE"}, TypeIDSize: model.DefaultCharacterSize, Kind: model.TypeID}}}},
				currentSchema: model.Collection{"table2": model.Fields{"id": &model.FieldType{FieldName: "id", IsFieldTypeRequired: true, IsPrimary: true}}, "table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsForeign: true, JointTable: &model.TableProperties{Table: "table2", To: "id", ConstraintName: GetConstraintName("table2", "id"), OnDelete: "CASCADE"}, Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "Mysql no queries generated when both schemas have 2 fields 1 with type ID & other having type ID with index",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table2": model.Fields{"id": &model.FieldType{FieldName: "id", IsFieldTypeRequired: true, IsPrimary: true}}, "table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IndexInfo: []*model.TableProperties{{IsIndex: true, Group: "group1", Order: 1, Sort: "asc"}}, TypeIDSize: model.DefaultCharacterSize, Kind: model.TypeID}}}},
				currentSchema: model.Collection{"table2": model.Fields{"id": &model.FieldType{FieldName: "id", IsFieldTypeRequired: true, IsPrimary: true}}, "table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IndexInfo: []*model.TableProperties{{IsIndex: true, Group: "group1", Order: 1, Sort: "asc"}}, Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "Mysql no queries generated when both schemas have 3 fields 1 with type ID & other having type ID with index in group1",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table2": model.Fields{"id": &model.FieldType{FieldName: "id", IsFieldTypeRequired: true, Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true}}, "table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IndexInfo: []*model.TableProperties{{IsIndex: true, Group: "group1", Order: 1, Sort: "asc"}}, Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize}, "col3": &model.FieldType{FieldName: "col3", IndexInfo: []*model.TableProperties{{IsIndex: true, Group: "group1", Order: 2, Sort: "asc"}}, TypeIDSize: model.DefaultCharacterSize, Kind: model.TypeID}}}},
				currentSchema: model.Collection{"table2": model.Fields{"id": &model.FieldType{FieldName: "id", IsFieldTypeRequired: true, Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true}}, "table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IndexInfo: []*model.TableProperties{{IsIndex: true, Group: "group1", Order: 1, Sort: "asc"}}, Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize}, "col3": &model.FieldType{FieldName: "col3", IndexInfo: []*model.TableProperties{{IsIndex: true, Group: "group1", Order: 2, Sort: "asc"}}, Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "Mysql no queries generated when both schemas have 2 fields 1 with type ID & other having type ID with index",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table2": model.Fields{"id": &model.FieldType{FieldName: "id", IsFieldTypeRequired: true, IsPrimary: true}}, "table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IndexInfo: []*model.TableProperties{{IsUnique: true, Group: "group1", Order: 1, Sort: "asc"}}, TypeIDSize: model.DefaultCharacterSize, Kind: model.TypeID}}}},
				currentSchema: model.Collection{"table2": model.Fields{"id": &model.FieldType{FieldName: "id", IsFieldTypeRequired: true, IsPrimary: true}}, "table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IndexInfo: []*model.TableProperties{{IsUnique: true, Group: "group1", Order: 1, Sort: "asc"}}, Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "Mysql no queries generated when both schemas have 3 fields 1 with type ID & other having type ID with index in group1",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table2": model.Fields{"id": &model.FieldType{FieldName: "id", IsFieldTypeRequired: true, IsPrimary: true}}, "table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IndexInfo: []*model.TableProperties{{IsUnique: true, Group: "group1", Order: 1, Sort: "asc"}}, Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize}, "col3": &model.FieldType{FieldName: "col3", IndexInfo: []*model.TableProperties{{IsUnique: true, Group: "group1", Order: 2, Sort: "asc"}}, TypeIDSize: model.DefaultCharacterSize, Kind: model.TypeID}}}},
				currentSchema: model.Collection{"table2": model.Fields{"id": &model.FieldType{FieldName: "id", IsFieldTypeRequired: true, IsPrimary: true}}, "table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IndexInfo: []*model.TableProperties{{IsUnique: true, Group: "group1", Order: 1, Sort: "asc"}}, Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize}, "col3": &model.FieldType{FieldName: "col3", IndexInfo: []*model.TableProperties{{IsUnique: true, Group: "group1", Order: 2, Sort: "asc"}}, Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "doing nthg composite",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, Group: "i1", Order: 1, Sort: "asc"}}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, Group: "i1", Order: 1, Sort: "asc"}}}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "doing nthg",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, Group: "i1", Order: 1, Sort: "asc"}}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, Group: "i1", Order: 1, Sort: "asc"}}}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		// 	SQL Server
		{
			name: "SQL-server no queries generated when both schemas have 2 fields with type Float",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", TypeIDSize: model.DefaultCharacterSize, Kind: model.TypeFloat}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeFloat, TypeIDSize: model.DefaultCharacterSize}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "SQL-server no queries generated when both schemas have 2 fields with type Decimal",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", TypeIDSize: model.DefaultCharacterSize, Kind: model.TypeDecimal, Args: &model.FieldArgs{Precision: 10, Scale: 5}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeDecimal, TypeIDSize: model.DefaultCharacterSize, Args: &model.FieldArgs{Precision: 10, Scale: 5}}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "SQL-Server no queries generated when both schemas have 2 fields with type ID",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", TypeIDSize: model.DefaultCharacterSize, Kind: model.TypeID}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "SQL-Server no queries generated when both schemas have 2 fields 1 with type ID & other having type String",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeString}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeString}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "SQL-Server no queries generated when both schemas have 2 fields 1 with type ID & other having type Integer",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeInteger}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeInteger}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "SQL-Server no queries generated when both schemas have 2 fields 1 with type ID & other having type Float",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeFloat, Args: &model.FieldArgs{Scale: model.DefaultScale, Precision: model.DefaultPrecision}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeFloat, Args: &model.FieldArgs{Scale: model.DefaultScale, Precision: model.DefaultPrecision}}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "SQL-Server no queries generated when both schemas have 2 fields 1 with type ID & other having type DateTime",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeDateTime, Args: &model.FieldArgs{Precision: model.DefaultDateTimePrecision}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeDateTime, Args: &model.FieldArgs{Precision: model.DefaultDateTimePrecision}}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "SQL-Server no queries generated when both schemas have 2 fields with type ID not null",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsFieldTypeRequired: true, TypeIDSize: model.DefaultCharacterSize, Kind: model.TypeID}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsFieldTypeRequired: true, Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "SQL-Server no queries generated when both schemas have 2 fields 1 with type ID & other having type String not null",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsFieldTypeRequired: true, Kind: model.TypeString}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsFieldTypeRequired: true, Kind: model.TypeString}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "SQL-Server no queries generated when both schemas have 2 fields 1 with type ID & other having type Integer not null",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsFieldTypeRequired: true, Kind: model.TypeInteger}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsFieldTypeRequired: true, Kind: model.TypeInteger}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "SQL-Server no queries generated when both schemas have 2 fields 1 with type ID & other having type Float not null",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsFieldTypeRequired: true, Kind: model.TypeFloat, Args: &model.FieldArgs{Scale: model.DefaultScale, Precision: model.DefaultPrecision}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsFieldTypeRequired: true, Kind: model.TypeFloat, Args: &model.FieldArgs{Scale: model.DefaultScale, Precision: model.DefaultPrecision}}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "SQL-Server no queries generated when both schemas have 2 fields 1 with type ID & other having type DateTime not null",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsFieldTypeRequired: true, Kind: model.TypeDateTime, Args: &model.FieldArgs{Precision: model.DefaultDateTimePrecision}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsFieldTypeRequired: true, Kind: model.TypeDateTime, Args: &model.FieldArgs{Precision: model.DefaultDateTimePrecision}}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "SQL-Server no queries generated when both schemas have 2 fields with type ID with default value",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsDefault: true, Default: "INDIA", TypeIDSize: model.DefaultCharacterSize, Kind: model.TypeID}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsDefault: true, Default: "INDIA", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "SQL-Server no queries generated when both schemas have 2 fields 1 with type ID & other having type String with default value",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsDefault: true, Default: "INDIA", Kind: model.TypeString}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsDefault: true, Default: "INDIA", Kind: model.TypeString}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "SQL-Server no queries generated when both schemas have 2 fields 1 with type ID & other having type Integer with default value",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsDefault: true, Default: "100", Kind: model.TypeInteger}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsDefault: true, Default: "100", Kind: model.TypeInteger}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "SQL-Server no queries generated when both schemas have 2 fields 1 with type ID & other having type Float with default value",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsDefault: true, Default: "9.8", Kind: model.TypeFloat, Args: &model.FieldArgs{Scale: model.DefaultScale, Precision: model.DefaultPrecision}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsDefault: true, Default: "9.8", Kind: model.TypeFloat, Args: &model.FieldArgs{Scale: model.DefaultScale, Precision: model.DefaultPrecision}}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "SQL-Server no queries generated when both schemas have 2 fields 1 with type ID & other having type DateTime with default value",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsDefault: true, Default: "2020-05-30T00:42:05+00:00", Kind: model.TypeDateTime, Args: &model.FieldArgs{Precision: model.DefaultDateTimePrecision}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsDefault: true, Default: "2020-05-30T00:42:05+00:00", Kind: model.TypeDateTime, Args: &model.FieldArgs{Precision: model.DefaultDateTimePrecision}}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "SQL-Server no queries generated when both schemas have only 1 primary key",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "SQL-Server no queries generated when both schemas have 2 fields 1 with type ID & other having type ID with foreign key",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table2": model.Fields{"id": &model.FieldType{FieldName: "id", IsFieldTypeRequired: true, IsPrimary: true}}, "table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsForeign: true, JointTable: &model.TableProperties{Table: "table2", To: "id", ConstraintName: GetConstraintName("table2", "id"), OnDelete: "NO ACTION"}, TypeIDSize: model.DefaultCharacterSize, Kind: model.TypeID}}}},
				currentSchema: model.Collection{"table2": model.Fields{"id": &model.FieldType{FieldName: "id", IsFieldTypeRequired: true, IsPrimary: true}}, "table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsForeign: true, JointTable: &model.TableProperties{Table: "table2", To: "id", ConstraintName: GetConstraintName("table2", "id"), OnDelete: "NO ACTION"}, Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "SQL-Server no queries generated when both schemas have 2 fields 1 with type ID & other having type ID with foreign key on delete CASCADE",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table2": model.Fields{"id": &model.FieldType{FieldName: "id", IsFieldTypeRequired: true, IsPrimary: true}}, "table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsForeign: true, JointTable: &model.TableProperties{Table: "table2", To: "id", ConstraintName: GetConstraintName("table2", "id"), OnDelete: "CASCADE"}, TypeIDSize: model.DefaultCharacterSize, Kind: model.TypeID}}}},
				currentSchema: model.Collection{"table2": model.Fields{"id": &model.FieldType{FieldName: "id", IsFieldTypeRequired: true, IsPrimary: true}}, "table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsForeign: true, JointTable: &model.TableProperties{Table: "table2", To: "id", ConstraintName: GetConstraintName("table2", "id"), OnDelete: "CASCADE"}, Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "SQL-Server no queries generated when both schemas have 2 fields 1 with type ID & other having type ID with index",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table2": model.Fields{"id": &model.FieldType{FieldName: "id", IsFieldTypeRequired: true, IsPrimary: true}}, "table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IndexInfo: []*model.TableProperties{{IsIndex: true, Group: "group1", Order: 1, Sort: "asc"}}, TypeIDSize: model.DefaultCharacterSize, Kind: model.TypeID}}}},
				currentSchema: model.Collection{"table2": model.Fields{"id": &model.FieldType{FieldName: "id", IsFieldTypeRequired: true, IsPrimary: true}}, "table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IndexInfo: []*model.TableProperties{{IsIndex: true, Group: "group1", Order: 1, Sort: "asc"}}, Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "SQL-Server no queries generated when both schemas have 3 fields 1 with type ID & other having type ID with index in group1",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table2": model.Fields{"id": &model.FieldType{FieldName: "id", IsFieldTypeRequired: true, IsPrimary: true}}, "table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IndexInfo: []*model.TableProperties{{IsIndex: true, Group: "group1", Order: 1, Sort: "asc"}}, Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize}, "col3": &model.FieldType{FieldName: "col3", IndexInfo: []*model.TableProperties{{IsIndex: true, Group: "group1", Order: 2, Sort: "asc"}}, TypeIDSize: model.DefaultCharacterSize, Kind: model.TypeID}}}},
				currentSchema: model.Collection{"table2": model.Fields{"id": &model.FieldType{FieldName: "id", IsFieldTypeRequired: true, IsPrimary: true}}, "table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IndexInfo: []*model.TableProperties{{IsIndex: true, Group: "group1", Order: 1, Sort: "asc"}}, Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize}, "col3": &model.FieldType{FieldName: "col3", IndexInfo: []*model.TableProperties{{IsIndex: true, Group: "group1", Order: 2, Sort: "asc"}}, Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "SQL-Server no queries generated when both schemas have 2 fields 1 with type ID & other having type ID with index",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table2": model.Fields{"id": &model.FieldType{FieldName: "id", IsFieldTypeRequired: true, IsPrimary: true}}, "table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IndexInfo: []*model.TableProperties{{IsUnique: true, Group: "group1", Order: 1, Sort: "asc"}}, TypeIDSize: model.DefaultCharacterSize, Kind: model.TypeID}}}},
				currentSchema: model.Collection{"table2": model.Fields{"id": &model.FieldType{FieldName: "id", IsFieldTypeRequired: true, IsPrimary: true}}, "table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IndexInfo: []*model.TableProperties{{IsUnique: true, Group: "group1", Order: 1, Sort: "asc"}}, Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "SQL-Server no queries generated when both schemas have 3 fields 1 with type ID & other having type ID with index in group1",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table2": model.Fields{"id": &model.FieldType{FieldName: "id", IsFieldTypeRequired: true, IsPrimary: true}}, "table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IndexInfo: []*model.TableProperties{{IsUnique: true, Group: "group1", Order: 1, Sort: "asc"}}, Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize}, "col3": &model.FieldType{FieldName: "col3", IndexInfo: []*model.TableProperties{{IsUnique: true, Group: "group1", Order: 2, Sort: "asc"}}, TypeIDSize: model.DefaultCharacterSize, Kind: model.TypeID}}}},
				currentSchema: model.Collection{"table2": model.Fields{"id": &model.FieldType{FieldName: "id", IsFieldTypeRequired: true, IsPrimary: true}}, "table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IndexInfo: []*model.TableProperties{{IsUnique: true, Group: "group1", Order: 1, Sort: "asc"}}, Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize}, "col3": &model.FieldType{FieldName: "col3", IndexInfo: []*model.TableProperties{{IsUnique: true, Group: "group1", Order: 2, Sort: "asc"}}, Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{},
			wantErr: false,
		},

		{
			name: "doing nthg",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, Group: "i1", Order: 1, Sort: "asc"}}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, Group: "i1", Order: 1, Sort: "asc"}}}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "doing nthg composite",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, Group: "i1", Order: 1, Sort: "asc"}}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, Group: "i1", Order: 1, Sort: "asc"}}}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		// 	Postgres
		{
			name: "Postgres no queries generated when both schemas have 2 fields with type Float",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", TypeIDSize: model.DefaultCharacterSize, Kind: model.TypeFloat}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeFloat, TypeIDSize: model.DefaultCharacterSize}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "Postgres no queries generated when both schemas have 2 fields with type Decimal",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", TypeIDSize: model.DefaultCharacterSize, Kind: model.TypeDecimal, Args: &model.FieldArgs{Precision: 10, Scale: 5}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeDecimal, TypeIDSize: model.DefaultCharacterSize, Args: &model.FieldArgs{Precision: 10, Scale: 5}}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "Postgres no queries generated when both schemas have 2 fields with type ID",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", TypeIDSize: model.DefaultCharacterSize, Kind: model.TypeID}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "Postgres no queries generated when both schemas have 2 fields 1 with type ID & other having type String",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeString}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeString}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "Postgres no queries generated when both schemas have 2 fields 1 with type ID & other having type Integer",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeInteger}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeInteger}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "Postgres no queries generated when both schemas have 2 fields 1 with type ID & other having type Float",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeFloat, Args: &model.FieldArgs{Scale: model.DefaultScale, Precision: model.DefaultPrecision}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeFloat, Args: &model.FieldArgs{Scale: model.DefaultScale, Precision: model.DefaultPrecision}}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "Postgres no queries generated when both schemas have 2 fields 1 with type ID & other having type DateTime",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeDateTime, Args: &model.FieldArgs{Precision: model.DefaultDateTimePrecision}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeDateTime, Args: &model.FieldArgs{Precision: model.DefaultDateTimePrecision}}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "Postgres no queries generated when both schemas have 2 fields 1 with type ID & other having type JSON",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeJSON}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeJSON}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "Postgres no queries generated when both schemas have 2 fields with type ID not null",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsFieldTypeRequired: true, TypeIDSize: model.DefaultCharacterSize, Kind: model.TypeID}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsFieldTypeRequired: true, Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "Postgres no queries generated when both schemas have 2 fields 1 with type ID & other having type String not null",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsFieldTypeRequired: true, Kind: model.TypeString}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsFieldTypeRequired: true, Kind: model.TypeString}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "Postgres no queries generated when both schemas have 2 fields 1 with type ID & other having type Integer not null",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsFieldTypeRequired: true, Kind: model.TypeInteger}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsFieldTypeRequired: true, Kind: model.TypeInteger}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "Postgres no queries generated when both schemas have 2 fields 1 with type ID & other having type Float not null",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsFieldTypeRequired: true, Kind: model.TypeFloat, Args: &model.FieldArgs{Scale: model.DefaultScale, Precision: model.DefaultPrecision}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsFieldTypeRequired: true, Kind: model.TypeFloat, Args: &model.FieldArgs{Scale: model.DefaultScale, Precision: model.DefaultPrecision}}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "Postgres no queries generated when both schemas have 2 fields 1 with type ID & other having type DateTime not null",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsFieldTypeRequired: true, Kind: model.TypeDateTime, Args: &model.FieldArgs{Precision: model.DefaultDateTimePrecision}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsFieldTypeRequired: true, Kind: model.TypeDateTime, Args: &model.FieldArgs{Precision: model.DefaultDateTimePrecision}}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "Postgres no queries generated when both schemas have 2 fields 1 with type ID & other having type JSON not null",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsFieldTypeRequired: true, Kind: model.TypeJSON}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsFieldTypeRequired: true, Kind: model.TypeJSON}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "Postgres no queries generated when both schemas have 2 fields with type ID with default value",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsDefault: true, Default: "INDIA", TypeIDSize: model.DefaultCharacterSize, Kind: model.TypeID}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsDefault: true, Default: "INDIA", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "Postgres no queries generated when both schemas have 2 fields 1 with type ID & other having type String with default value",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsDefault: true, Default: "INDIA", Kind: model.TypeString}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsDefault: true, Default: "INDIA", Kind: model.TypeString}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "Postgres no queries generated when both schemas have 2 fields 1 with type ID & other having type Integer with default value",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsDefault: true, Default: "100", Kind: model.TypeInteger}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsDefault: true, Default: "100", Kind: model.TypeInteger}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "Postgres no queries generated when both schemas have 2 fields 1 with type ID & other having type Float with default value",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsDefault: true, Default: "9.8", Kind: model.TypeFloat, Args: &model.FieldArgs{Scale: model.DefaultScale, Precision: model.DefaultPrecision}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsDefault: true, Default: "9.8", Kind: model.TypeFloat, Args: &model.FieldArgs{Scale: model.DefaultScale, Precision: model.DefaultPrecision}}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "Postgres no queries generated when both schemas have 2 fields 1 with type ID & other having type DateTime with default value",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsDefault: true, Default: "2020-05-30T00:42:05+00:00", Kind: model.TypeDateTime, Args: &model.FieldArgs{Precision: model.DefaultDateTimePrecision}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsDefault: true, Default: "2020-05-30T00:42:05+00:00", Kind: model.TypeDateTime, Args: &model.FieldArgs{Precision: model.DefaultDateTimePrecision}}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "Postgres no queries generated when both schemas have 2 fields 1 with type ID & other having type JSON with default value",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsDefault: true, Default: `{"id":"zerfvnex","name":"john"}`, Kind: model.TypeJSON}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsDefault: true, Default: `{"id":"zerfvnex","name":"john"}`, Kind: model.TypeJSON}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "Postgres no queries generated when both schemas have only 1 primary key",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "Postgres no queries generated when both schemas have 2 fields 1 with type ID & other having type ID with foreign key",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table2": model.Fields{"id": &model.FieldType{FieldName: "id", IsFieldTypeRequired: true, IsPrimary: true}}, "table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsForeign: true, JointTable: &model.TableProperties{Table: "table2", To: "id", ConstraintName: GetConstraintName("table2", "id"), OnDelete: "NO ACTION"}, TypeIDSize: model.DefaultCharacterSize, Kind: model.TypeID}}}},
				currentSchema: model.Collection{"table2": model.Fields{"id": &model.FieldType{FieldName: "id", IsFieldTypeRequired: true, IsPrimary: true}}, "table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsForeign: true, JointTable: &model.TableProperties{Table: "table2", To: "id", ConstraintName: GetConstraintName("table2", "id"), OnDelete: "NO ACTION"}, Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "Postgres no queries generated when both schemas have 2 fields 1 with type ID & other having type ID with foreign key on delete CASCADE",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table2": model.Fields{"id": &model.FieldType{FieldName: "id", IsFieldTypeRequired: true, IsPrimary: true}}, "table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsForeign: true, JointTable: &model.TableProperties{Table: "table2", To: "id", ConstraintName: GetConstraintName("table2", "id"), OnDelete: "CASCADE"}, TypeIDSize: model.DefaultCharacterSize, Kind: model.TypeID}}}},
				currentSchema: model.Collection{"table2": model.Fields{"id": &model.FieldType{FieldName: "id", IsFieldTypeRequired: true, IsPrimary: true}}, "table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IsForeign: true, JointTable: &model.TableProperties{Table: "table2", To: "id", ConstraintName: GetConstraintName("table2", "id"), OnDelete: "CASCADE"}, Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "Postgres no queries generated when both schemas have 2 fields 1 with type ID & other having type ID with index",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table2": model.Fields{"id": &model.FieldType{FieldName: "id", IsFieldTypeRequired: true, IsPrimary: true}}, "table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IndexInfo: []*model.TableProperties{{IsIndex: true, Group: "group1", Order: 1, Sort: "asc"}}, TypeIDSize: model.DefaultCharacterSize, Kind: model.TypeID}}}},
				currentSchema: model.Collection{"table2": model.Fields{"id": &model.FieldType{FieldName: "id", IsFieldTypeRequired: true, IsPrimary: true}}, "table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IndexInfo: []*model.TableProperties{{IsIndex: true, Group: "group1", Order: 1, Sort: "asc"}}, Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "Postgres no queries generated when both schemas have 3 fields 1 with type ID & other having type ID with index in group1",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table2": model.Fields{"id": &model.FieldType{FieldName: "id", IsFieldTypeRequired: true, IsPrimary: true}}, "table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IndexInfo: []*model.TableProperties{{IsIndex: true, Group: "group1", Order: 1, Sort: "asc"}}, Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize}, "col3": &model.FieldType{FieldName: "col3", IndexInfo: []*model.TableProperties{{IsIndex: true, Group: "group1", Order: 2, Sort: "asc"}}, TypeIDSize: model.DefaultCharacterSize, Kind: model.TypeID}}}},
				currentSchema: model.Collection{"table2": model.Fields{"id": &model.FieldType{FieldName: "id", IsFieldTypeRequired: true, IsPrimary: true}}, "table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IndexInfo: []*model.TableProperties{{IsIndex: true, Group: "group1", Order: 1, Sort: "asc"}}, Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize}, "col3": &model.FieldType{FieldName: "col3", IndexInfo: []*model.TableProperties{{IsIndex: true, Group: "group1", Order: 2, Sort: "asc"}}, Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "Postgres no queries generated when both schemas have 2 fields 1 with type ID & other having type ID with index",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table2": model.Fields{"id": &model.FieldType{FieldName: "id", IsFieldTypeRequired: true, IsPrimary: true}}, "table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IndexInfo: []*model.TableProperties{{IsUnique: true, Group: "group1", Order: 1, Sort: "asc"}}, TypeIDSize: model.DefaultCharacterSize, Kind: model.TypeID}}}},
				currentSchema: model.Collection{"table2": model.Fields{"id": &model.FieldType{FieldName: "id", IsFieldTypeRequired: true, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, TypeIDSize: model.DefaultCharacterSize}}, "table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IndexInfo: []*model.TableProperties{{IsUnique: true, Group: "group1", Order: 1, Sort: "asc"}}, Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "Postgres no queries generated when both schemas have 3 fields 1 with type ID & other having type ID with index in group1",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table2": model.Fields{"id": &model.FieldType{FieldName: "id", IsFieldTypeRequired: true, IsPrimary: true}}, "table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IndexInfo: []*model.TableProperties{{IsUnique: true, Group: "group1", Order: 1, Sort: "asc"}}, Kind: model.TypeID}, "col3": &model.FieldType{FieldName: "col3", IndexInfo: []*model.TableProperties{{IsUnique: true, Group: "group1", Order: 2, Sort: "asc"}}, TypeIDSize: model.DefaultCharacterSize, Kind: model.TypeID}}}},
				currentSchema: model.Collection{"table2": model.Fields{"id": &model.FieldType{FieldName: "id", IsFieldTypeRequired: true, IsPrimary: true}}, "table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", IndexInfo: []*model.TableProperties{{IsUnique: true, Group: "group1", Order: 1, Sort: "asc"}}, Kind: model.TypeID}, "col3": &model.FieldType{FieldName: "col3", IndexInfo: []*model.TableProperties{{IsUnique: true, Group: "group1", Order: 2, Sort: "asc"}}, Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "doing nthg",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, Group: "i1", Order: 1, Sort: "asc"}}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, Group: "i1", Order: 1, Sort: "asc"}}}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "doing nthg composite",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, Group: "i1", Order: 1, Sort: "asc"}}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, Group: "i1", Order: 1, Sort: "asc"}}}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{},
			wantErr: false,
		},
	}
	var createTableTestCases = []testGenerateCreationQueries{
		// Mysql
		{
			name: "Mysql adding a table and column of type Decimal default values",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"id": &model.FieldType{FieldName: "id", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsFieldTypeRequired: true, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}}, "col1": &model.FieldType{FieldName: "col1", Kind: model.TypeDecimal, IsFieldTypeRequired: true, Args: &model.FieldArgs{Precision: model.DefaultPrecision, Scale: model.DefaultScale}}}}},
				currentSchema: model.Collection{},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"CREATE TABLE table1 (id varchar(100) NOT NULL , col1 decimal(38,10) NOT NULL ,PRIMARY KEY (id));"},
			wantErr: false,
		},
		{
			name: "Mysql adding a table and column of type Decimal",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"id": &model.FieldType{FieldName: "id", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsFieldTypeRequired: true, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}}, "col1": &model.FieldType{FieldName: "col1", Kind: model.TypeDecimal, IsFieldTypeRequired: true, Args: &model.FieldArgs{Precision: 10, Scale: 5}}}}},
				currentSchema: model.Collection{},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"CREATE TABLE table1 (id varchar(100) NOT NULL , col1 decimal(10,5) NOT NULL ,PRIMARY KEY (id));"},
			wantErr: false,
		},
		{
			name: "Mysql adding a table and column of type JSON",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"id": &model.FieldType{FieldName: "id", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsFieldTypeRequired: true, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}}, "col1": &model.FieldType{FieldName: "col1", Kind: model.TypeJSON, IsFieldTypeRequired: true}}}},
				currentSchema: model.Collection{},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"CREATE TABLE table1 (id varchar(100) NOT NULL , col1 json NOT NULL ,PRIMARY KEY (id));"},
			wantErr: false,
		},
		{
			name: "Mysql adding a table and column of type int with default key",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"id": &model.FieldType{FieldName: "id", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IsFieldTypeRequired: true, IsDefault: true, Default: 543}}}},
				currentSchema: model.Collection{},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"CREATE TABLE table1 (id varchar(100) NOT NULL , col1 integer NOT NULL ,PRIMARY KEY (id));", "ALTER TABLE table1 MODIFY COLUMN col1 integer DEFAULT(543)"},
			wantErr: false,
		},
		{
			name: "Mysql adding a table and column of type bigint with default key",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"id": &model.FieldType{FieldName: "id", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col1": &model.FieldType{FieldName: "col1", Kind: model.TypeBigInteger, IsFieldTypeRequired: true, IsDefault: true, Default: 543}}}},
				currentSchema: model.Collection{},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"CREATE TABLE table1 (id varchar(100) NOT NULL , col1 bigint NOT NULL ,PRIMARY KEY (id));", "ALTER TABLE table1 MODIFY COLUMN col1 bigint DEFAULT(543)"},
			wantErr: false,
		},
		{
			name: "Mysql adding a table and column of type smallint with default key",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"id": &model.FieldType{FieldName: "id", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col1": &model.FieldType{FieldName: "col1", Kind: model.TypeSmallInteger, IsFieldTypeRequired: true, IsDefault: true, Default: 543}}}},
				currentSchema: model.Collection{},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"CREATE TABLE table1 (id varchar(100) NOT NULL , col1 smallint NOT NULL ,PRIMARY KEY (id));", "ALTER TABLE table1 MODIFY COLUMN col1 smallint DEFAULT(543)"},
			wantErr: false,
		},
		{
			name: "Mysql: adding a table and column of type float with default key",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"id": &model.FieldType{FieldName: "id", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col1": &model.FieldType{FieldName: "col1", Kind: model.TypeFloat, Args: &model.FieldArgs{Scale: model.DefaultScale, Precision: model.DefaultPrecision}, IsFieldTypeRequired: true, IsDefault: true, Default: 5.2}}}},
				currentSchema: model.Collection{},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"CREATE TABLE table1 (id varchar(100) NOT NULL , col1 double NOT NULL ,PRIMARY KEY (id));", "ALTER TABLE table1 MODIFY COLUMN col1 double DEFAULT(5.2)"},
			wantErr: false,
		},
		{
			name: "Mysql: adding a table and column of type string with default key",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"id": &model.FieldType{FieldName: "id", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col1": &model.FieldType{FieldName: "col1", Kind: model.TypeString, IsFieldTypeRequired: true, IsDefault: true, Default: "string"}}}},
				currentSchema: model.Collection{},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"CREATE TABLE table1 (id varchar(100) NOT NULL , col1 longtext NOT NULL ,PRIMARY KEY (id));", "ALTER TABLE table1 MODIFY COLUMN col1 longtext DEFAULT('string')"},
			wantErr: false,
		},
		{
			name: "adding a table and column of type boolean with default key",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"id": &model.FieldType{FieldName: "id", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col1": &model.FieldType{FieldName: "col1", Kind: model.TypeBoolean, IsFieldTypeRequired: true, IsDefault: true, Default: true}}}},
				currentSchema: model.Collection{},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"CREATE TABLE table1 (id varchar(100) NOT NULL , col1 tinyint(1) NOT NULL ,PRIMARY KEY (id));", "ALTER TABLE table1 MODIFY COLUMN col1 tinyint(1) DEFAULT(true)"},
			wantErr: false,
		},
		{
			name: "removing a table and column of type boolean with default key",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeBoolean}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeBoolean, IsDefault: true, Default: true}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"ALTER TABLE table1 ALTER col1 DROP DEFAULT"},
			wantErr: false,
		},
		{
			name: "mysql: adding two columns",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeString}}}},
				currentSchema: model.Collection{"table1": model.Fields{}},
			},
			isSort:  true,
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"ALTER TABLE table1 ADD col1 varchar(100)", "ALTER TABLE table1 ADD col2 longtext"},
			wantErr: false,
		},
		{
			name: "adding a table and column of type integer",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"id": &model.FieldType{FieldName: "id", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IsForeign: true, JointTable: &model.TableProperties{Table: "table2", ConstraintName: GetConstraintName("table1", "col1"), To: "id"}}}}},
				currentSchema: model.Collection{"table2": model.Fields{}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"CREATE TABLE table1 (id varchar(100) NOT NULL , col1 integer ,PRIMARY KEY (id));", "ALTER TABLE table1 ADD CONSTRAINT c_table1_col1 FOREIGN KEY (col1) REFERENCES table2 (id)"},
			wantErr: false,
		},
		{
			name: "mysql: adding a table and a foreign key",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"id": &model.FieldType{FieldName: "id", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeDateTime, Args: &model.FieldArgs{Precision: model.DefaultDateTimePrecision}, IsForeign: true, JointTable: &model.TableProperties{Table: "table2", ConstraintName: GetConstraintName("table1", "col2"), To: "id"}}}}},
				currentSchema: model.Collection{"table2": model.Fields{}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"CREATE TABLE table1 (id varchar(100) NOT NULL , col2 datetime(6) ,PRIMARY KEY (id));", "ALTER TABLE table1 ADD CONSTRAINT c_table1_col2 FOREIGN KEY (col2) REFERENCES table2 (id)"},
			wantErr: false,
		},
		{
			name: "mysql: adding a table and a foreign key with ON DELETE CASCADE",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"id": &model.FieldType{FieldName: "id", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeDateTime, Args: &model.FieldArgs{Precision: model.DefaultDateTimePrecision}, IsForeign: true, JointTable: &model.TableProperties{Table: "table2", To: "id", ConstraintName: GetConstraintName("table1", "col2"), OnDelete: "CASCADE"}}}}},
				currentSchema: model.Collection{"table2": model.Fields{}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"CREATE TABLE table1 (id varchar(100) NOT NULL , col2 datetime(6) ,PRIMARY KEY (id));", "ALTER TABLE table1 ADD CONSTRAINT c_table1_col2 FOREIGN KEY (col2) REFERENCES table2 (id) ON DELETE CASCADE"},
			wantErr: false,
		},
		{
			name: "current Schema with NO ACTION and parsedSchema with ON CASCADE DELETE ",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeDateTime, Args: &model.FieldArgs{Precision: model.DefaultPrecision, Scale: model.DefaultScale}, IsForeign: true, JointTable: &model.TableProperties{Table: "table2", ConstraintName: GetConstraintName("table1", "col1"), To: "id", OnDelete: "CASCADE"}}}}},
				currentSchema: model.Collection{"table2": model.Fields{}, "table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeDateTime, Args: &model.FieldArgs{Precision: model.DefaultPrecision, Scale: model.DefaultScale}, IsForeign: true, JointTable: &model.TableProperties{Table: "table2", ConstraintName: GetConstraintName("table1", "col1"), To: "id"}}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"ALTER TABLE table1 DROP FOREIGN KEY c_table1_col1", "ALTER TABLE table1 DROP INDEX c_table1_col1", "ALTER TABLE table1 ADD CONSTRAINT c_table1_col1 FOREIGN KEY (col1) REFERENCES table2 (id) ON DELETE CASCADE"},
			wantErr: false,
		},
		{
			name: "current Schema with CASCADE and parsedSchema with NO ACTION ",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeDateTime, Args: &model.FieldArgs{Precision: model.DefaultPrecision, Scale: model.DefaultScale}, IsForeign: true, JointTable: &model.TableProperties{Table: "table2", ConstraintName: GetConstraintName("table1", "col1"), To: "id"}}}}},
				currentSchema: model.Collection{"table2": model.Fields{}, "table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeDateTime, Args: &model.FieldArgs{Precision: model.DefaultPrecision, Scale: model.DefaultScale}, IsForeign: true, JointTable: &model.TableProperties{Table: "table2", ConstraintName: GetConstraintName("table1", "col1"), To: "id", OnDelete: "CASCADE"}}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"ALTER TABLE table1 DROP FOREIGN KEY c_table1_col1", "ALTER TABLE table1 DROP INDEX c_table1_col1", "ALTER TABLE table1 ADD CONSTRAINT c_table1_col1 FOREIGN KEY (col1) REFERENCES table2 (id)"},
			wantErr: false,
		},
		{
			name: "adding a table and column of type boolean",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"id": &model.FieldType{FieldName: "id", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col1": &model.FieldType{FieldName: "col1", Kind: model.TypeBoolean, IsForeign: true, JointTable: &model.TableProperties{Table: "table2", ConstraintName: GetConstraintName("table1", "col1"), To: "id"}}}}},
				currentSchema: model.Collection{"table2": model.Fields{}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"CREATE TABLE table1 (id varchar(100) NOT NULL , col1 tinyint(1) ,PRIMARY KEY (id));", "ALTER TABLE table1 ADD CONSTRAINT c_table1_col1 FOREIGN KEY (col1) REFERENCES table2 (id)"},
			wantErr: false,
		},
		{
			name: "mysql: adding a table and a primary key",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col3": &model.FieldType{FieldName: "col3", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsFieldTypeRequired: true, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}}}}},
				currentSchema: model.Collection{},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"CREATE TABLE table1 (col3 varchar(100) NOT NULL , PRIMARY KEY (col3));"},
			wantErr: false,
		},
		// 	SQL Server
		{
			name: "SQL-server adding a table and column of type Decimal default values",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"id": &model.FieldType{FieldName: "id", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsFieldTypeRequired: true, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}}, "col1": &model.FieldType{FieldName: "col1", Kind: model.TypeDecimal, IsFieldTypeRequired: true, Args: &model.FieldArgs{Precision: model.DefaultPrecision, Scale: model.DefaultScale}}}}},
				currentSchema: model.Collection{},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{"CREATE TABLE test.table1 (id nvarchar(100) NOT NULL , col1 decimal(38,10) NOT NULL ,PRIMARY KEY (id));"},
			wantErr: false,
		},
		{
			name: "SQL-server adding a table and column of type Decimal",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"id": &model.FieldType{FieldName: "id", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsFieldTypeRequired: true, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}}, "col1": &model.FieldType{FieldName: "col1", Kind: model.TypeDecimal, IsFieldTypeRequired: true, Args: &model.FieldArgs{Precision: 10, Scale: 5}}}}},
				currentSchema: model.Collection{},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{"CREATE TABLE test.table1 (id nvarchar(100) NOT NULL , col1 decimal(10,5) NOT NULL ,PRIMARY KEY (id));"},
			wantErr: false,
		},
		{
			name: "adding a table and column of type JSON",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"id": &model.FieldType{FieldName: "id", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col1": &model.FieldType{FieldName: "col1", Kind: model.TypeJSON, IsFieldTypeRequired: true}}}},
				currentSchema: model.Collection{},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{"CREATE TABLE test.table1 (id nvarchar(100) NOT NULL , col1 nvarchar(max) constraint json_check_table1_col1 CHECK (ISJSON(col1)=1) NOT NULL ,PRIMARY KEY (id));"},
			wantErr: false,
		},
		{
			name: "adding a table and column of type int with default key",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"id": &model.FieldType{FieldName: "id", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IsFieldTypeRequired: true, IsDefault: true, Default: 543}}}},
				currentSchema: model.Collection{},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{"CREATE TABLE test.table1 (id nvarchar(100) NOT NULL , col1 integer NOT NULL ,PRIMARY KEY (id));", "ALTER TABLE test.table1 ADD CONSTRAINT c_col1 DEFAULT 543 FOR col1"},
			wantErr: false,
		},
		{
			name: "adding a table and column of type bigint with default key",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"id": &model.FieldType{FieldName: "id", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col1": &model.FieldType{FieldName: "col1", Kind: model.TypeBigInteger, IsFieldTypeRequired: true, IsDefault: true, Default: 543}}}},
				currentSchema: model.Collection{},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{"CREATE TABLE test.table1 (id nvarchar(100) NOT NULL , col1 bigint NOT NULL ,PRIMARY KEY (id));", "ALTER TABLE test.table1 ADD CONSTRAINT c_col1 DEFAULT 543 FOR col1"},
			wantErr: false,
		},
		{
			name: "adding a table and column of type smallint with default key",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"id": &model.FieldType{FieldName: "id", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col1": &model.FieldType{FieldName: "col1", Kind: model.TypeSmallInteger, IsFieldTypeRequired: true, IsDefault: true, Default: 543}}}},
				currentSchema: model.Collection{},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{"CREATE TABLE test.table1 (id nvarchar(100) NOT NULL , col1 smallint NOT NULL ,PRIMARY KEY (id));", "ALTER TABLE test.table1 ADD CONSTRAINT c_col1 DEFAULT 543 FOR col1"},
			wantErr: false,
		},
		{
			name: "Sql server: adding a table and column of type float with default key",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"id": &model.FieldType{FieldName: "id", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col1": &model.FieldType{FieldName: "col1", Kind: model.TypeFloat, Args: &model.FieldArgs{Scale: model.DefaultScale, Precision: model.DefaultPrecision}, IsFieldTypeRequired: true, IsDefault: true, Default: 5.2}}}},
				currentSchema: model.Collection{},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{"CREATE TABLE test.table1 (id nvarchar(100) NOT NULL , col1 float NOT NULL ,PRIMARY KEY (id));", "ALTER TABLE test.table1 ADD CONSTRAINT c_col1 DEFAULT 5.2 FOR col1"},
			wantErr: false,
		},
		{
			name: "Sql-server: adding a table and column of type string with default key",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"id": &model.FieldType{FieldName: "id", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col1": &model.FieldType{FieldName: "col1", Kind: model.TypeString, IsFieldTypeRequired: true, IsDefault: true, Default: "string"}}}},
				currentSchema: model.Collection{},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{"CREATE TABLE test.table1 (id nvarchar(100) NOT NULL , col1 nvarchar(max) NOT NULL ,PRIMARY KEY (id));", "ALTER TABLE test.table1 ADD CONSTRAINT c_col1 DEFAULT 'string' FOR col1"},
			wantErr: false,
		},
		{
			name: "removing a table and column of type boolean with default key",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeBoolean}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeBoolean, IsDefault: true, Default: true}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{"ALTER TABLE test.table1 DROP CONSTRAINT c_col1"},
			wantErr: false,
		},
		{
			name: "adding a table and column of type boolean with default key",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"id": &model.FieldType{FieldName: "id", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col1": &model.FieldType{FieldName: "col1", Kind: model.TypeBoolean, IsFieldTypeRequired: true, IsDefault: true, Default: true}}}},
				currentSchema: model.Collection{},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{"CREATE TABLE test.table1 (id nvarchar(100) NOT NULL , col1 bit NOT NULL ,PRIMARY KEY (id));", "ALTER TABLE test.table1 ADD CONSTRAINT c_col1 DEFAULT 1 FOR col1"},
			wantErr: false,
		},
		{
			name: "sqlserver: adding two columns",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeString}}}},
				currentSchema: model.Collection{"table1": model.Fields{}},
			},
			isSort:  true,
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{"ALTER TABLE test.table1 ADD col1 nvarchar(100)", "ALTER TABLE test.table1 ADD col2 nvarchar(max)"},
			wantErr: false,
		},
		{
			name: "adding a table and column of type integer",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"id": &model.FieldType{FieldName: "id", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IsForeign: true, JointTable: &model.TableProperties{Table: "table2", ConstraintName: GetConstraintName("table1", "col1"), To: "id"}}}}},
				currentSchema: model.Collection{"table2": model.Fields{}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{"CREATE TABLE test.table1 (id nvarchar(100) NOT NULL , col1 integer ,PRIMARY KEY (id));", "ALTER TABLE test.table1 ADD CONSTRAINT c_table1_col1 FOREIGN KEY (col1) REFERENCES test.table2 (id)"},
			wantErr: false,
		},
		{
			name: "sqlserver: adding a table and a foreign key",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"id": &model.FieldType{FieldName: "id", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeDateTime, Args: &model.FieldArgs{Precision: model.DefaultDateTimePrecision}, IsForeign: true, JointTable: &model.TableProperties{Table: "table2", ConstraintName: GetConstraintName("table1", "col2"), To: "id"}}}}},
				currentSchema: model.Collection{"table2": model.Fields{}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{"CREATE TABLE test.table1 (id nvarchar(100) NOT NULL , col2 datetime2(6) ,PRIMARY KEY (id));", "ALTER TABLE test.table1 ADD CONSTRAINT c_table1_col2 FOREIGN KEY (col2) REFERENCES test.table2 (id)"},
			wantErr: false,
		},
		{
			name: "sqlserver: adding a table and a foreign key with ON DELETE CASCADE",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"id": &model.FieldType{FieldName: "id", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeDateTime, Args: &model.FieldArgs{Precision: model.DefaultDateTimePrecision}, IsForeign: true, JointTable: &model.TableProperties{Table: "table2", ConstraintName: GetConstraintName("table1", "col2"), To: "id", OnDelete: "CASCADE"}}}}},
				currentSchema: model.Collection{"table2": model.Fields{}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{"CREATE TABLE test.table1 (id nvarchar(100) NOT NULL , col2 datetime2(6) ,PRIMARY KEY (id));", "ALTER TABLE test.table1 ADD CONSTRAINT c_table1_col2 FOREIGN KEY (col2) REFERENCES test.table2 (id) ON DELETE CASCADE"},
			wantErr: false,
		},
		{
			name: "current Schema with NO ACTION and parsedSchema with ON CASCADE DELETE ",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeDateTime, Args: &model.FieldArgs{Precision: model.DefaultDateTimePrecision}, IsForeign: true, JointTable: &model.TableProperties{Table: "table2", ConstraintName: GetConstraintName("table1", "col1"), To: "id", OnDelete: "CASCADE"}}}}},
				currentSchema: model.Collection{"table2": model.Fields{}, "table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeDateTime, Args: &model.FieldArgs{Precision: model.DefaultDateTimePrecision}, IsForeign: true, JointTable: &model.TableProperties{Table: "table2", ConstraintName: GetConstraintName("table1", "col1"), To: "id"}}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{"ALTER TABLE test.table1 DROP CONSTRAINT c_table1_col1", "ALTER TABLE test.table1 ADD CONSTRAINT c_table1_col1 FOREIGN KEY (col1) REFERENCES test.table2 (id) ON DELETE CASCADE"},
			wantErr: false,
		},
		{
			name: "current Schema with CASCADE and parsedSchema with NO ACTION ",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeDateTime, Args: &model.FieldArgs{Precision: model.DefaultDateTimePrecision}, IsForeign: true, JointTable: &model.TableProperties{Table: "table2", ConstraintName: GetConstraintName("table1", "col1"), To: "id"}}}}},
				currentSchema: model.Collection{"table2": model.Fields{}, "table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeDateTime, Args: &model.FieldArgs{Precision: model.DefaultDateTimePrecision}, IsForeign: true, JointTable: &model.TableProperties{Table: "table2", ConstraintName: GetConstraintName("table1", "col1"), To: "id", OnDelete: "CASCADE"}}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{"ALTER TABLE test.table1 DROP CONSTRAINT c_table1_col1", "ALTER TABLE test.table1 ADD CONSTRAINT c_table1_col1 FOREIGN KEY (col1) REFERENCES test.table2 (id)"},
			wantErr: false,
		},
		{
			name: "adding a table and column of type boolean",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"id": &model.FieldType{FieldName: "id", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col1": &model.FieldType{FieldName: "col1", Kind: model.TypeBoolean, IsForeign: true, JointTable: &model.TableProperties{Table: "table2", ConstraintName: GetConstraintName("table1", "col1"), To: "id"}}}}},
				currentSchema: model.Collection{"table2": model.Fields{}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{"CREATE TABLE test.table1 (id nvarchar(100) NOT NULL , col1 bit ,PRIMARY KEY (id));", "ALTER TABLE test.table1 ADD CONSTRAINT c_table1_col1 FOREIGN KEY (col1) REFERENCES test.table2 (id)"},
			wantErr: false,
		},
		{
			name: "sqlserver: adding a table and a primary key",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col3": &model.FieldType{FieldName: "col3", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsFieldTypeRequired: true, PrimaryKeyInfo: &model.TableProperties{}, IsPrimary: true}}}},
				currentSchema: model.Collection{"table2": model.Fields{}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{"CREATE TABLE test.table1 (col3 nvarchar(100) NOT NULL , PRIMARY KEY (col3));"},
			wantErr: false,
		},
		// 	Postgres
		{
			name: "Postgres adding a table and column of type Decimal default values",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"id": &model.FieldType{FieldName: "id", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsFieldTypeRequired: true, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}}, "col1": &model.FieldType{FieldName: "col1", Kind: model.TypeDecimal, IsFieldTypeRequired: true, Args: &model.FieldArgs{Precision: model.DefaultPrecision, Scale: model.DefaultScale}}}}},
				currentSchema: model.Collection{},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{"CREATE TABLE test.table1 (id character varying(100) NOT NULL , col1 numeric(38,10) NOT NULL ,PRIMARY KEY (id));"},
			wantErr: false,
		},
		{
			name: "Postgres adding a table and column of type Decimal",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"id": &model.FieldType{FieldName: "id", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsFieldTypeRequired: true, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}}, "col1": &model.FieldType{FieldName: "col1", Kind: model.TypeDecimal, IsFieldTypeRequired: true, Args: &model.FieldArgs{Precision: 10, Scale: 5}}}}},
				currentSchema: model.Collection{},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{"CREATE TABLE test.table1 (id character varying(100) NOT NULL , col1 numeric(10,5) NOT NULL ,PRIMARY KEY (id));"},
			wantErr: false,
		},
		{

			name: "adding a table and column of type JSON",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"id": &model.FieldType{FieldName: "id", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col1": &model.FieldType{FieldName: "col1", Kind: model.TypeJSON, IsFieldTypeRequired: true}}}},
				currentSchema: model.Collection{},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{"CREATE TABLE test.table1 (id character varying(100) NOT NULL , col1 jsonb NOT NULL ,PRIMARY KEY (id));"},
			wantErr: false,
		},
		{
			name: "adding a table and column of type integer with default key",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"id": &model.FieldType{FieldName: "id", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IsFieldTypeRequired: true, IsDefault: true, Default: 543}}}},
				currentSchema: model.Collection{},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{"CREATE TABLE test.table1 (id character varying(100) NOT NULL , col1 integer NOT NULL ,PRIMARY KEY (id));", "ALTER TABLE test.table1 ALTER COLUMN col1 SET DEFAULT 543"},
			wantErr: false,
		},
		{
			name: "adding a table and column of type bigint with default key",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"id": &model.FieldType{FieldName: "id", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col1": &model.FieldType{FieldName: "col1", Kind: model.TypeBigInteger, IsFieldTypeRequired: true, IsDefault: true, Default: 543}}}},
				currentSchema: model.Collection{},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{"CREATE TABLE test.table1 (id character varying(100) NOT NULL , col1 bigint NOT NULL ,PRIMARY KEY (id));", "ALTER TABLE test.table1 ALTER COLUMN col1 SET DEFAULT 543"},
			wantErr: false,
		},
		{
			name: "adding a table and column of type integer with default key",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"id": &model.FieldType{FieldName: "id", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col1": &model.FieldType{FieldName: "col1", Kind: model.TypeSmallInteger, IsFieldTypeRequired: true, IsDefault: true, Default: 543}}}},
				currentSchema: model.Collection{},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{"CREATE TABLE test.table1 (id character varying(100) NOT NULL , col1 smallint NOT NULL ,PRIMARY KEY (id));", "ALTER TABLE test.table1 ALTER COLUMN col1 SET DEFAULT 543"},
			wantErr: false,
		},
		{
			name: "Postgres: adding a table and column of type float with default key",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"id": &model.FieldType{FieldName: "id", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col1": &model.FieldType{FieldName: "col1", Kind: model.TypeFloat, Args: &model.FieldArgs{Scale: model.DefaultScale, Precision: model.DefaultPrecision}, IsFieldTypeRequired: true, IsDefault: true, Default: 5.2}}}},
				currentSchema: model.Collection{},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{"CREATE TABLE test.table1 (id character varying(100) NOT NULL , col1 double precision NOT NULL ,PRIMARY KEY (id));", "ALTER TABLE test.table1 ALTER COLUMN col1 SET DEFAULT 5.2"},
			wantErr: false,
		},
		{
			name: "Postgres: adding a table and column of type string with default key",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"id": &model.FieldType{FieldName: "id", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col1": &model.FieldType{FieldName: "col1", Kind: model.TypeString, IsFieldTypeRequired: true, IsDefault: true, Default: "string"}}}},
				currentSchema: model.Collection{},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{"CREATE TABLE test.table1 (id character varying(100) NOT NULL , col1 text NOT NULL ,PRIMARY KEY (id));", "ALTER TABLE test.table1 ALTER COLUMN col1 SET DEFAULT 'string'"},
			wantErr: false,
		},
		{
			name: "adding a table and column of type boolean with default key",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"id": &model.FieldType{FieldName: "id", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col1": &model.FieldType{FieldName: "col1", Kind: model.TypeBoolean, IsFieldTypeRequired: true, IsDefault: true, Default: true}}}},
				currentSchema: model.Collection{},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{"CREATE TABLE test.table1 (id character varying(100) NOT NULL , col1 boolean NOT NULL ,PRIMARY KEY (id));", "ALTER TABLE test.table1 ALTER COLUMN col1 SET DEFAULT true"},
			wantErr: false,
		},
		{
			name: "postgres: adding two columns",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeString}}}},
				currentSchema: model.Collection{"table1": model.Fields{}},
			},
			isSort:  true,
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{"ALTER TABLE test.table1 ADD COLUMN col1 character varying(100)", "ALTER TABLE test.table1 ADD COLUMN col2 text"},
			wantErr: false,
		},
		{
			name: "adding a table and column of type integer",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"id": &model.FieldType{FieldName: "id", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IsForeign: true, JointTable: &model.TableProperties{Table: "table2", ConstraintName: GetConstraintName("table1", "col1"), To: "id"}}}}},
				currentSchema: model.Collection{"table2": model.Fields{}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{"CREATE TABLE test.table1 (id character varying(100) NOT NULL , col1 integer ,PRIMARY KEY (id));", "ALTER TABLE test.table1 ADD CONSTRAINT c_table1_col1 FOREIGN KEY (col1) REFERENCES test.table2 (id)"},
			wantErr: false,
		},
		{
			name: "postgres: adding a table and a foreign key",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"id": &model.FieldType{FieldName: "id", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeDateTime, Args: &model.FieldArgs{Precision: model.DefaultDateTimePrecision}, IsForeign: true, JointTable: &model.TableProperties{Table: "table2", ConstraintName: GetConstraintName("table1", "col2"), To: "id"}}}}},
				currentSchema: model.Collection{"table2": model.Fields{}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{"CREATE TABLE test.table1 (id character varying(100) NOT NULL , col2 timestamp(6) without time zone ,PRIMARY KEY (id));", "ALTER TABLE test.table1 ADD CONSTRAINT c_table1_col2 FOREIGN KEY (col2) REFERENCES test.table2 (id)"},
			wantErr: false,
		},
		{
			name: "postgres: adding a table and a foreign key with ON CASCADE DELETE",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"id": &model.FieldType{FieldName: "id", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeDateTime, Args: &model.FieldArgs{Precision: model.DefaultDateTimePrecision}, IsForeign: true, JointTable: &model.TableProperties{Table: "table2", ConstraintName: GetConstraintName("table1", "col2"), To: "id", OnDelete: "CASCADE"}}}}},
				currentSchema: model.Collection{"table2": model.Fields{}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{"CREATE TABLE test.table1 (id character varying(100) NOT NULL , col2 timestamp(6) without time zone ,PRIMARY KEY (id));", "ALTER TABLE test.table1 ADD CONSTRAINT c_table1_col2 FOREIGN KEY (col2) REFERENCES test.table2 (id) ON DELETE CASCADE"},
			wantErr: false,
		},
		{
			name: "current Schema with NO ACTION and parsedSchema with ON CASCADE DELETE ",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeDateTime, Args: &model.FieldArgs{Precision: model.DefaultDateTimePrecision}, IsForeign: true, JointTable: &model.TableProperties{Table: "table2", ConstraintName: GetConstraintName("table1", "col1"), To: "id", OnDelete: "CASCADE"}}}}},
				currentSchema: model.Collection{"table2": model.Fields{}, "table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeDateTime, Args: &model.FieldArgs{Precision: model.DefaultDateTimePrecision}, IsForeign: true, JointTable: &model.TableProperties{Table: "table2", ConstraintName: GetConstraintName("table1", "col1"), To: "id"}}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{"ALTER TABLE test.table1 DROP CONSTRAINT c_table1_col1", "ALTER TABLE test.table1 ADD CONSTRAINT c_table1_col1 FOREIGN KEY (col1) REFERENCES test.table2 (id) ON DELETE CASCADE"},
			wantErr: false,
		},
		{
			name: "current Schema with CASCADE and parsedSchema with NO ACTION ",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeDateTime, Args: &model.FieldArgs{Precision: model.DefaultDateTimePrecision}, IsForeign: true, JointTable: &model.TableProperties{Table: "table2", ConstraintName: GetConstraintName("table1", "col1"), To: "id"}}}}},
				currentSchema: model.Collection{"table2": model.Fields{}, "table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeDateTime, Args: &model.FieldArgs{Precision: model.DefaultDateTimePrecision}, IsForeign: true, JointTable: &model.TableProperties{Table: "table2", ConstraintName: GetConstraintName("table1", "col1"), To: "id", OnDelete: "CASCADE"}}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{"ALTER TABLE test.table1 DROP CONSTRAINT c_table1_col1", "ALTER TABLE test.table1 ADD CONSTRAINT c_table1_col1 FOREIGN KEY (col1) REFERENCES test.table2 (id)"},
			wantErr: false,
		},
		{
			name: "adding a table and column of type boolean",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"id": &model.FieldType{FieldName: "id", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col1": &model.FieldType{FieldName: "col1", Kind: model.TypeBoolean, IsForeign: true, JointTable: &model.TableProperties{Table: "table2", ConstraintName: GetConstraintName("table1", "col1"), To: "id"}}}}},
				currentSchema: model.Collection{"table2": model.Fields{}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{"CREATE TABLE test.table1 (id character varying(100) NOT NULL , col1 boolean ,PRIMARY KEY (id));", "ALTER TABLE test.table1 ADD CONSTRAINT c_table1_col1 FOREIGN KEY (col1) REFERENCES test.table2 (id)"},
			wantErr: false,
		},
		{
			name: "postgres: adding a table and a primary key",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col3": &model.FieldType{FieldName: "col3", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsFieldTypeRequired: true, PrimaryKeyInfo: &model.TableProperties{}, IsPrimary: true}}}},
				currentSchema: model.Collection{"table2": model.Fields{}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{"CREATE TABLE test.table1 (col3 character varying(100) NOT NULL , PRIMARY KEY (col3));"},
			wantErr: false,
		},
	}
	var dropColumTestCases = []testGenerateCreationQueries{
		// Mysql
		{
			name: "removing one column",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"ALTER TABLE table1 DROP COLUMN col1"},
			wantErr: false,
		},
		// sql-server
		{
			name: "removing one column",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{"ALTER TABLE test.table1 DROP COLUMN col1"},
			wantErr: false,
		},
		// postgres
		{
			name: "removing one column",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{"ALTER TABLE test.table1 DROP COLUMN col1"},
			wantErr: false,
		},
	}
	var changingNotNullOfColumnTestCases = []testGenerateCreationQueries{
		// Mysql
		{
			name: "mysql: required to unrequired",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsFieldTypeRequired: true}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"ALTER TABLE table1 MODIFY col1 varchar(100) NOT NULL"},
			wantErr: false,
		},
		{
			name: "mysql: unrequired to required",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsFieldTypeRequired: true}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"ALTER TABLE table1 MODIFY col1 varchar(100) NULL"},
			wantErr: false,
		},
		// 	SQL Server
		{
			name: "sqlserver: required to unrequired",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsFieldTypeRequired: true}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{"ALTER TABLE test.table1 ALTER COLUMN col1 nvarchar(100) NOT NULL"},
			wantErr: false,
		},
		{
			name: "sqlserver: unrequired to required",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", TypeIDSize: model.DefaultCharacterSize, Kind: model.TypeID}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsFieldTypeRequired: true}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{"ALTER TABLE test.table1 ALTER COLUMN col1 nvarchar(100) NULL"},
			wantErr: false,
		},
		// 	Postgres
		{
			name: "postgres: required to unrequired",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsFieldTypeRequired: true}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{"ALTER TABLE test.table1 ALTER COLUMN col1 SET NOT NULL"},
			wantErr: false,
		},
		{
			name: "postgres: unrequired to required",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", TypeIDSize: model.DefaultCharacterSize, Kind: model.TypeID}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsFieldTypeRequired: true}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{"ALTER TABLE test.table1 ALTER COLUMN col1 DROP NOT NULL"},
			wantErr: false,
		},
	}
	var changingTypeOfColumnTestCases = []testGenerateCreationQueries{
		// 	Mysql
		{
			name: "Mysql: integer to decimal",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeDecimal, Args: &model.FieldArgs{Scale: model.DefaultScale, Precision: model.DefaultPrecision}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"ALTER TABLE table1 DROP COLUMN col1", "ALTER TABLE table1 ADD col1 decimal(38,10)"},
			wantErr: false,
		},
		{
			name: "Mysql: integer to float",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeFloat, Args: &model.FieldArgs{Scale: model.DefaultScale, Precision: model.DefaultPrecision}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"ALTER TABLE table1 DROP COLUMN col1", "ALTER TABLE table1 ADD col1 double"},
			wantErr: false,
		},
		{
			name: "mysql: integer to string",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeString}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"ALTER TABLE table1 DROP COLUMN col1", "ALTER TABLE table1 ADD col1 longtext"},
			wantErr: false,
		},
		{
			name: "integer to JSON",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeJSON}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"ALTER TABLE table1 DROP COLUMN col1", "ALTER TABLE table1 ADD col1 json"},
			wantErr: false,
		},
		{
			name: "int to bigint",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeBigInteger}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"ALTER TABLE table1 DROP COLUMN col1", "ALTER TABLE table1 ADD col1 bigint"},
			wantErr: false,
		},
		{
			name: "int to smallint",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeSmallInteger}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"ALTER TABLE table1 DROP COLUMN col1", "ALTER TABLE table1 ADD col1 smallint"},
			wantErr: false,
		},
		{
			name: "JSON to integer",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeJSON}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"ALTER TABLE table1 DROP COLUMN col1", "ALTER TABLE table1 ADD col1 integer"},
			wantErr: false,
		},
		{
			name: "JSON to bigint",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeBigInteger}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeJSON}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"ALTER TABLE table1 DROP COLUMN col1", "ALTER TABLE table1 ADD col1 bigint"},
			wantErr: false,
		},
		{
			name: "JSON to decimal",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeDecimal, Args: &model.FieldArgs{Precision: model.DefaultPrecision, Scale: model.DefaultScale}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeJSON}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"ALTER TABLE table1 DROP COLUMN col1", "ALTER TABLE table1 ADD col1 decimal(38,10)"},
			wantErr: false,
		},
		{
			name: "JSON to smallint",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeSmallInteger}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeJSON}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"ALTER TABLE table1 DROP COLUMN col1", "ALTER TABLE table1 ADD col1 smallint"},
			wantErr: false,
		},
		{
			name: "mysql: JSON to string",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeString}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeJSON}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"ALTER TABLE table1 DROP COLUMN col1", "ALTER TABLE table1 ADD col1 longtext"},
			wantErr: false,
		},
		{
			name: "string to decimal",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeDecimal, Args: &model.FieldArgs{Precision: model.DefaultPrecision, Scale: model.DefaultScale}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeString}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"ALTER TABLE table1 DROP COLUMN col1", "ALTER TABLE table1 ADD col1 decimal(38,10)"},
			wantErr: false,
		},
		{
			name: "string to integer",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeString}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"ALTER TABLE table1 DROP COLUMN col1", "ALTER TABLE table1 ADD col1 integer"},
			wantErr: false,
		},
		{
			name: "float to integer",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeFloat}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"ALTER TABLE table1 DROP COLUMN col1", "ALTER TABLE table1 ADD col1 integer"},
			wantErr: false,
		},
		{
			name: "float to decimal",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeDecimal, Args: &model.FieldArgs{Precision: model.DefaultPrecision, Scale: model.DefaultScale}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeFloat}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"ALTER TABLE table1 DROP COLUMN col1", "ALTER TABLE table1 ADD col1 decimal(38,10)"},
			wantErr: false,
		},
		{
			name: "mysql: float to dateTime",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeDateTime, Args: &model.FieldArgs{Precision: model.DefaultDateTimePrecision}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeFloat}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"ALTER TABLE table1 DROP COLUMN col1", "ALTER TABLE table1 ADD col1 datetime(6)"},
			wantErr: false,
		},
		{
			name: "Mysql: datetime to float",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeFloat, Args: &model.FieldArgs{Scale: model.DefaultScale, Precision: model.DefaultPrecision}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeDateTime, Args: &model.FieldArgs{Precision: model.DefaultDateTimePrecision}}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"ALTER TABLE table1 DROP COLUMN col1", "ALTER TABLE table1 ADD col1 double"},
			wantErr: false,
		},
		{
			name: "mysql: datetime to id",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeDateTime, Args: &model.FieldArgs{Precision: model.DefaultDateTimePrecision}}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"ALTER TABLE table1 DROP COLUMN col1", "ALTER TABLE table1 ADD col1 varchar(100)"},
			wantErr: false,
		},
		{
			name: "mysql: id to datetime",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeDateTime, Args: &model.FieldArgs{Precision: model.DefaultDateTimePrecision}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"ALTER TABLE table1 DROP COLUMN col1", "ALTER TABLE table1 ADD col1 datetime(6)"},
			wantErr: false,
		},
		// 	SQL server
		{
			name: "sqlserver: integer to string",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeString}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{"ALTER TABLE test.table1 DROP COLUMN col1", "ALTER TABLE test.table1 ADD col1 nvarchar(max)"},
			wantErr: false,
		},
		{
			name: "string to integer",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeString}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{"ALTER TABLE test.table1 DROP COLUMN col1", "ALTER TABLE test.table1 ADD col1 integer"},
			wantErr: false,
		},
		{
			name: "integer to float",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeFloat, Args: &model.FieldArgs{Scale: model.DefaultScale, Precision: model.DefaultPrecision}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{"ALTER TABLE test.table1 DROP COLUMN col1", "ALTER TABLE test.table1 ADD col1 float"},
			wantErr: false,
		},
		{
			name: "Sql server integer to bigint",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeBigInteger}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{"ALTER TABLE test.table1 DROP COLUMN col1", "ALTER TABLE test.table1 ADD col1 bigint"},
			wantErr: false,
		},
		{
			name: "Sql server integer to smallint",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeSmallInteger}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{"ALTER TABLE test.table1 DROP COLUMN col1", "ALTER TABLE test.table1 ADD col1 smallint"},
			wantErr: false,
		},
		{
			name: "float to integer",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeFloat}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{"ALTER TABLE test.table1 DROP COLUMN col1", "ALTER TABLE test.table1 ADD col1 integer"},
			wantErr: false,
		},
		{
			name: "sqlserver: float to dateTime",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeDateTime, Args: &model.FieldArgs{Precision: model.DefaultDateTimePrecision}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeFloat}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{"ALTER TABLE test.table1 DROP COLUMN col1", "ALTER TABLE test.table1 ADD col1 datetime2(6)"},
			wantErr: false,
		},
		{
			name: "datetime to float",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeFloat, Args: &model.FieldArgs{Scale: model.DefaultScale, Precision: model.DefaultPrecision}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeDateTime, Args: &model.FieldArgs{Precision: model.DefaultDateTimePrecision}}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{"ALTER TABLE test.table1 DROP COLUMN col1", "ALTER TABLE test.table1 ADD col1 float"},
			wantErr: false,
		},
		{
			name: "sqlserver: datetime to id",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", TypeIDSize: model.DefaultCharacterSize, Kind: model.TypeID}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeDateTime, Args: &model.FieldArgs{Precision: model.DefaultDateTimePrecision}}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{"ALTER TABLE test.table1 DROP COLUMN col1", "ALTER TABLE test.table1 ADD col1 nvarchar(100)"},
			wantErr: false,
		},
		{
			name: "sqlserver: id to datetime",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeDateTime, Args: &model.FieldArgs{Precision: model.DefaultDateTimePrecision}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{"ALTER TABLE test.table1 DROP COLUMN col1", "ALTER TABLE test.table1 ADD col1 datetime2(6)"},
			wantErr: false,
		},
		// 	Postgres
		{
			name: "integer to JSON",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeJSON}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{"ALTER TABLE test.table1 DROP COLUMN col1", "ALTER TABLE test.table1 ADD COLUMN col1 jsonb"},
			wantErr: false,
		},
		{
			name: "Postgres integer to bigint",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeBigInteger}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{"ALTER TABLE test.table1 DROP COLUMN col1", "ALTER TABLE test.table1 ADD COLUMN col1 bigint"},
			wantErr: false,
		},
		{
			name: "Postgres integer to smallint",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeSmallInteger}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{"ALTER TABLE test.table1 DROP COLUMN col1", "ALTER TABLE test.table1 ADD COLUMN col1 smallint"},
			wantErr: false,
		},
		{
			name: "JSON to integer",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeJSON}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{"ALTER TABLE test.table1 DROP COLUMN col1", "ALTER TABLE test.table1 ADD COLUMN col1 integer"},
			wantErr: false,
		},
		{
			name: "JSON to string",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeString}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeJSON}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{"ALTER TABLE test.table1 DROP COLUMN col1", "ALTER TABLE test.table1 ADD COLUMN col1 text"},
			wantErr: false,
		},
		{
			name: "postgres: integer to string",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeString}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{"ALTER TABLE test.table1 DROP COLUMN col1", "ALTER TABLE test.table1 ADD COLUMN col1 text"},
			wantErr: false,
		},
		{
			name: "string to integer",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeString}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{"ALTER TABLE test.table1 DROP COLUMN col1", "ALTER TABLE test.table1 ADD COLUMN col1 integer"},
			wantErr: false,
		},
		{
			name: "integer to float",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeFloat, Args: &model.FieldArgs{Scale: model.DefaultScale, Precision: model.DefaultPrecision}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{"ALTER TABLE test.table1 DROP COLUMN col1", "ALTER TABLE test.table1 ADD COLUMN col1 double precision"},
			wantErr: false,
		},
		{
			name: "float to integer",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeFloat}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{"ALTER TABLE test.table1 DROP COLUMN col1", "ALTER TABLE test.table1 ADD COLUMN col1 integer"},
			wantErr: false,
		},
		{
			name: "postgres: float to dateTime",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeDateTime, Args: &model.FieldArgs{Precision: model.DefaultDateTimePrecision}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeFloat}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{"ALTER TABLE test.table1 DROP COLUMN col1", "ALTER TABLE test.table1 ADD COLUMN col1 timestamp(6) without time zone"},
			wantErr: false,
		},
		{
			name: "datetime to float",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeFloat, Args: &model.FieldArgs{Scale: model.DefaultScale, Precision: model.DefaultPrecision}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeDateTime, Args: &model.FieldArgs{Precision: model.DefaultDateTimePrecision}}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{"ALTER TABLE test.table1 DROP COLUMN col1", "ALTER TABLE test.table1 ADD COLUMN col1 double precision"},
			wantErr: false,
		},
		{
			name: "postgres: datetime to id",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", TypeIDSize: model.DefaultCharacterSize, Kind: model.TypeID}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeDateTime, Args: &model.FieldArgs{Precision: model.DefaultDateTimePrecision}}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{"ALTER TABLE test.table1 DROP COLUMN col1", "ALTER TABLE test.table1 ADD COLUMN col1 character varying(100)"},
			wantErr: false,
		},
		{
			name: "postgres: id to datetime",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeDateTime, Args: &model.FieldArgs{Precision: model.DefaultDateTimePrecision}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{"ALTER TABLE test.table1 DROP COLUMN col1", "ALTER TABLE test.table1 ADD COLUMN col1 timestamp(6) without time zone"},
			wantErr: false,
		},
	}
	var changingPrimaryKeyTestCases = []testGenerateCreationQueries{
		// 	Mysql
		{
			name: "cannot modify type of column with primary key - mysql",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeString, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", TypeIDSize: model.DefaultCharacterSize, Kind: model.TypeID}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{},
			wantErr: true,
		},
		{
			name: "changing type of column with primary key",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col3": &model.FieldType{FieldName: "col3", Kind: model.TypeInteger, IsFieldTypeRequired: true, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col3": &model.FieldType{FieldName: "col3", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsFieldTypeRequired: true, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{},
			wantErr: true,
		},
		{
			name: "adding primary directive to type Json",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeJSON, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}}}},
				currentSchema: model.Collection{},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{},
			wantErr: true,
		},
		{
			name: "trying to mutate a primary key",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsFieldTypeRequired: true, IsDefault: true}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsFieldTypeRequired: true, IsPrimary: true}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{},
			wantErr: true,
		},
		{
			name: "removing primary key",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsFieldTypeRequired: false, IsPrimary: false}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsFieldTypeRequired: true, IsPrimary: true}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{},
			wantErr: true,
		},
		{
			name: "cannot remove a column with primary key - mysql",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col2": &model.FieldType{FieldName: "col2", TypeIDSize: model.DefaultCharacterSize, Kind: model.TypeID}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{},
			wantErr: true,
		},
		// 	SQL server
		{
			name: "adding primary key",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsFieldTypeRequired: true, PrimaryKeyInfo: &model.TableProperties{}, IsPrimary: true}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{},
			wantErr: false,
		},
		{
			name: "removing primary key",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsFieldTypeRequired: false, IsPrimary: false}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsFieldTypeRequired: true, IsPrimary: true}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{},
			wantErr: true,
		},
		// 	Postgres
		{
			name: "adding primary directive to type Json",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeJSON, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}}}},
				currentSchema: model.Collection{},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{},
			wantErr: true,
		},
		{
			name: "mutating field with primary key",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsFieldTypeRequired: true, IsDefault: true}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{},
			wantErr: true,
		},
		{
			name: "removing primary key",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsFieldTypeRequired: false, IsPrimary: false}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsFieldTypeRequired: true, IsPrimary: true}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{},
			wantErr: true,
		},
	}
	var changingLinkTestCases = []testGenerateCreationQueries{
		{
			name: "mysql: adding link",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsLinked: true, LinkedTable: &model.TableProperties{Table: "table2", To: "id"}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"ALTER TABLE table1 DROP COLUMN col1"},
			wantErr: false,
		},
		{
			name: "mysql: removing link",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsFieldTypeRequired: false, IsForeign: false}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsLinked: true, LinkedTable: &model.TableProperties{Table: "table2", To: "id"}}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"ALTER TABLE table1 ADD col1 varchar(100)"},
			wantErr: false,
		},
		// Sql server
		{
			name: "sqlserver: adding link",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsLinked: true, LinkedTable: &model.TableProperties{Table: "table2", To: "id"}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{"ALTER TABLE test.table1 DROP COLUMN col1"},
			wantErr: false,
		},
		{
			name: "sqlserver: removing link",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsFieldTypeRequired: false, IsForeign: false}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsLinked: true, LinkedTable: &model.TableProperties{Table: "table2", To: "id"}}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{"ALTER TABLE test.table1 ADD col1 nvarchar(100)"},
			wantErr: false,
		},
		// 	Postgres
		{
			name: "postgres: adding link",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsLinked: true, LinkedTable: &model.TableProperties{Table: "table2", To: "id"}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{"ALTER TABLE test.table1 DROP COLUMN col1"},
			wantErr: false,
		},
		{
			name: "postgres: removing link",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsFieldTypeRequired: false, IsForeign: false}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsLinked: true, LinkedTable: &model.TableProperties{Table: "table2", To: "id"}}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{"ALTER TABLE test.table1 ADD COLUMN col1 character varying(100)"},
			wantErr: false,
		},
	}
	var changingForeignKeyTestCases = []testGenerateCreationQueries{
		{
			name: "adding foreign key",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsForeign: true, JointTable: &model.TableProperties{Table: "table2", ConstraintName: GetConstraintName("table1", "col1"), To: "id"}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsForeign: false}}, "table2": model.Fields{}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"ALTER TABLE table1 ADD CONSTRAINT c_table1_col1 FOREIGN KEY (col1) REFERENCES table2 (id)"},
			wantErr: false,
		},
		{
			name: "adding foreign key with type change",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IsForeign: true, JointTable: &model.TableProperties{Table: "table2", ConstraintName: GetConstraintName("table1", "col1"), To: "id"}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsForeign: false}}, "table2": model.Fields{}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"ALTER TABLE table1 DROP COLUMN col1", "ALTER TABLE table1 ADD col1 integer", "ALTER TABLE table1 ADD CONSTRAINT c_table1_col1 FOREIGN KEY (col1) REFERENCES table2 (id)"},
			wantErr: false,
		},
		{
			name: "removing foreign key",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsFieldTypeRequired: false, IsForeign: false}}, "table2": model.Fields{"id": &model.FieldType{FieldName: "col1", TypeIDSize: model.DefaultCharacterSize, Kind: model.TypeID}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsForeign: true, JointTable: &model.TableProperties{Table: "table2", ConstraintName: GetConstraintName("table1", "col1"), To: "id"}}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"ALTER TABLE table1 DROP FOREIGN KEY c_table1_col1", "ALTER TABLE table1 DROP INDEX c_table1_col1"},
			wantErr: false,
		},
		{
			name: "removing foreign key and type change",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IsFieldTypeRequired: false, IsForeign: false}}, "table2": model.Fields{"id": &model.FieldType{FieldName: "col1", TypeIDSize: model.DefaultCharacterSize, Kind: model.TypeID}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsForeign: true, JointTable: &model.TableProperties{Table: "table2", ConstraintName: GetConstraintName("table1", "col1"), To: "id"}}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"ALTER TABLE table1 DROP FOREIGN KEY c_table1_col1", "ALTER TABLE table1 DROP INDEX c_table1_col1", "ALTER TABLE table1 DROP COLUMN col1", "ALTER TABLE table1 ADD col1 integer"},
			wantErr: false,
		},
		{
			name: "adding foreign key",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsForeign: true, JointTable: &model.TableProperties{Table: "table2", ConstraintName: GetConstraintName("table1", "col1"), To: "id"}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsForeign: false}}, "table2": model.Fields{}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{"ALTER TABLE test.table1 ADD CONSTRAINT c_table1_col1 FOREIGN KEY (col1) REFERENCES test.table2 (id)"},
			wantErr: false,
		},
		{
			name: "adding foreign key with type change",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IsForeign: true, JointTable: &model.TableProperties{Table: "table2", ConstraintName: GetConstraintName("table1", "col1"), To: "id"}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsForeign: false}}, "table2": model.Fields{}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{"ALTER TABLE test.table1 DROP COLUMN col1", "ALTER TABLE test.table1 ADD col1 integer", "ALTER TABLE test.table1 ADD CONSTRAINT c_table1_col1 FOREIGN KEY (col1) REFERENCES test.table2 (id)"},
			wantErr: false,
		},
		{
			name: "removing foreign key",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsFieldTypeRequired: false, IsForeign: false}}, "table2": model.Fields{"id": &model.FieldType{FieldName: "col1", TypeIDSize: model.DefaultCharacterSize, Kind: model.TypeID}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsForeign: true, JointTable: &model.TableProperties{Table: "table2", ConstraintName: GetConstraintName("table1", "col1"), To: "id"}}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{"ALTER TABLE test.table1 DROP CONSTRAINT c_table1_col1"},
			wantErr: false,
		},
		{
			name: "removing foreign key and type change",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IsFieldTypeRequired: false, IsForeign: false}}, "table2": model.Fields{"id": &model.FieldType{FieldName: "col1", TypeIDSize: model.DefaultCharacterSize, Kind: model.TypeID}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsForeign: true, JointTable: &model.TableProperties{Table: "table2", ConstraintName: GetConstraintName("table1", "col1"), To: "id"}}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{"ALTER TABLE test.table1 DROP CONSTRAINT c_table1_col1", "ALTER TABLE test.table1 DROP COLUMN col1", "ALTER TABLE test.table1 ADD col1 integer"},
			wantErr: false,
		},
		// 	Postgres
		{
			name: "adding foreign key with type change",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IsForeign: true, JointTable: &model.TableProperties{Table: "table2", ConstraintName: GetConstraintName("table1", "col1"), To: "id"}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsForeign: false}}, "table2": model.Fields{}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{"ALTER TABLE test.table1 DROP COLUMN col1", "ALTER TABLE test.table1 ADD COLUMN col1 integer", "ALTER TABLE test.table1 ADD CONSTRAINT c_table1_col1 FOREIGN KEY (col1) REFERENCES test.table2 (id)"},
			wantErr: false,
		},
		{
			name: "removing foreign key",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsFieldTypeRequired: false, IsForeign: false}}, "table2": model.Fields{"id": &model.FieldType{FieldName: "col1", TypeIDSize: model.DefaultCharacterSize, Kind: model.TypeID}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsForeign: true, JointTable: &model.TableProperties{Table: "table2", ConstraintName: GetConstraintName("table1", "col1"), To: "id"}}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{"ALTER TABLE test.table1 DROP CONSTRAINT c_table1_col1"},
			wantErr: false,
		},
		{
			name: "removing foreign key and type change",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IsFieldTypeRequired: false, IsForeign: false}}, "table2": model.Fields{"id": &model.FieldType{FieldName: "col1", TypeIDSize: model.DefaultCharacterSize, Kind: model.TypeID}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsForeign: true, JointTable: &model.TableProperties{Table: "table2", ConstraintName: GetConstraintName("table1", "col1"), To: "id"}}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{"ALTER TABLE test.table1 DROP CONSTRAINT c_table1_col1", "ALTER TABLE test.table1 DROP COLUMN col1", "ALTER TABLE test.table1 ADD COLUMN col1 integer"},
			wantErr: false,
		},
	}
	var changingUniqueIndexKeyTestCases = []testGenerateCreationQueries{
		// 	Mysql
		{
			name: "adding unique directive to type Json",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeJSON, IsFieldTypeRequired: true, IndexInfo: []*model.TableProperties{{IsUnique: true}}}}}},
				currentSchema: model.Collection{},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{},
			wantErr: true,
		},
		{
			name: "adding unique key",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IsFieldTypeRequired: true, IndexInfo: []*model.TableProperties{{Field: "col1", IsUnique: true, IsIndex: true, Order: 1, Sort: "asc"}}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"ALTER TABLE table1 MODIFY col1 integer NOT NULL", "CREATE UNIQUE INDEX index__table1__ ON table1 (col1 asc)"},
			wantErr: false,
		},
		{
			name: "adding unique index key to existing index",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, IsUnique: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 1, Sort: "asc"}}}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col2", IsIndex: true, IsUnique: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 2, Sort: "asc"}}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, IsUnique: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 1, Sort: "asc"}}}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"ALTER TABLE table1 ADD col2 integer", "DROP INDEX index__table1__i1 ON table1", "CREATE UNIQUE INDEX index__table1__i1 ON table1 (col1 asc, col2 asc)"},
			wantErr: false,
		},
		{
			name: "adding new unique index key ",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, IsUnique: true, Group: "i1", Order: 1, Sort: "asc"}}}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col2", IsIndex: true, IsUnique: true, Group: "i2", Order: 1, Sort: "asc"}}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, IsUnique: true, Group: "i1", Order: 1, Sort: "asc"}}}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"ALTER TABLE table1 ADD col2 integer", "CREATE UNIQUE INDEX index__table1__i2 ON table1 (col2 asc)"},
			wantErr: false,
		},
		{
			name: "changing order of unique index key ",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, IsUnique: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 2, Sort: "asc"}}}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col2", IsIndex: true, IsUnique: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 1, Sort: "asc"}}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, IsUnique: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 1, Sort: "asc"}}}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col2", IsIndex: true, IsUnique: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 2, Sort: "asc"}}}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"DROP INDEX index__table1__i1 ON table1", "CREATE UNIQUE INDEX index__table1__i1 ON table1 (col2 asc, col1 asc)"},
			wantErr: false,
		},
		{
			name: "changing group of unique index key ",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, IsUnique: true, Group: "i2", ConstraintName: getIndexName("table1", "i2"), Order: 2, Sort: "asc"}}}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col2", IsIndex: true, IsUnique: true, Group: "i2", ConstraintName: getIndexName("table1", "i2"), Order: 1, Sort: "asc"}}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, IsUnique: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 1, Sort: "asc"}}}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col2", IsIndex: true, IsUnique: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 2, Sort: "asc"}}}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"DROP INDEX index__table1__i1 ON table1", "CREATE UNIQUE INDEX index__table1__i2 ON table1 (col2 asc, col1 asc)"},
			wantErr: false,
		},
		{
			name: "changing unique to index",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 1, Sort: "asc"}}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, IsUnique: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 1, Sort: "asc"}}}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"DROP INDEX index__table1__i1 ON table1", "CREATE INDEX index__table1__i1 ON table1 (col1 asc)"},
			wantErr: false,
		},
		{
			name: "changing sort of unique index key ",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, IsUnique: true, ConstraintName: getIndexName("table1", "i1"), Group: "i1", Order: 2, Sort: "asc"}}}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col2", IsIndex: true, IsUnique: true, ConstraintName: getIndexName("table1", "i1"), Group: "i1", Order: 1, Sort: "desc"}}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, IsUnique: true, ConstraintName: getIndexName("table1", "i1"), Group: "i1", Order: 1, Sort: "desc"}}}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col2", IsIndex: true, IsUnique: true, ConstraintName: getIndexName("table1", "i1"), Group: "i1", Order: 2, Sort: "asc"}}}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"DROP INDEX index__table1__i1 ON table1", "CREATE UNIQUE INDEX index__table1__i1 ON table1 (col2 desc, col1 asc)"},
			wantErr: false,
		},
		{
			name: "adding unique key",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IsFieldTypeRequired: true, IndexInfo: []*model.TableProperties{{Field: "col1", IsUnique: true, IsIndex: true, Order: 1, Sort: "asc"}}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{"ALTER TABLE test.table1 ALTER COLUMN col1 integer NOT NULL", "CREATE UNIQUE INDEX index__table1__ ON test.table1 (col1 asc)"},
			wantErr: false,
		},
		{
			name: "adding unique index key to existing index",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, IsUnique: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 1, Sort: "asc"}}}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col2", IsIndex: true, IsUnique: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 2, Sort: "asc"}}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, IsUnique: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 1, Sort: "asc"}}}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{"ALTER TABLE test.table1 ADD col2 integer", "DROP INDEX index__table1__i1 ON test.table1", "CREATE UNIQUE INDEX index__table1__i1 ON test.table1 (col1 asc, col2 asc)"},
			wantErr: false,
		},
		{
			name: "adding new unique index key ",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, IsUnique: true, Group: "i1", Order: 1, Sort: "asc"}}}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col2", IsIndex: true, IsUnique: true, Group: "i2", Order: 1, Sort: "asc"}}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, IsUnique: true, Group: "i1", Order: 1, Sort: "asc"}}}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{"ALTER TABLE test.table1 ADD col2 integer", "CREATE UNIQUE INDEX index__table1__i2 ON test.table1 (col2 asc)"},
			wantErr: false,
		},
		{
			name: "changing index to unique",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, IsUnique: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 1, Sort: "asc"}}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 1, Sort: "asc"}}}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{"DROP INDEX index__table1__i1 ON test.table1", "CREATE UNIQUE INDEX index__table1__i1 ON test.table1 (col1 asc)"},
			wantErr: false,
		},
		{
			name: "changing index to unique",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, IsUnique: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 1, Sort: "asc"}}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 1, Sort: "asc"}}}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{"DROP INDEX index__table1__i1 ON test.table1", "CREATE UNIQUE INDEX index__table1__i1 ON test.table1 (col1 asc)"},
			wantErr: false,
		},
		{
			name: "changing unique to index",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 1, Sort: "asc"}}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, IsUnique: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 1, Sort: "asc"}}}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{"DROP INDEX index__table1__i1 ON test.table1", "CREATE INDEX index__table1__i1 ON test.table1 (col1 asc)"},
			wantErr: false,
		},
		{
			name: "changing order of unique index key ",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, IsUnique: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 2, Sort: "asc"}}}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col2", IsIndex: true, IsUnique: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 1, Sort: "asc"}}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, IsUnique: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 1, Sort: "asc"}}}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col2", IsIndex: true, IsUnique: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 2, Sort: "asc"}}}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{"DROP INDEX index__table1__i1 ON test.table1", "CREATE UNIQUE INDEX index__table1__i1 ON test.table1 (col2 asc, col1 asc)"},
			wantErr: false,
		},
		{
			name: "changing group of unique index key ",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, IsUnique: true, ConstraintName: getIndexName("table1", "i2"), Group: "i2", Order: 2, Sort: "asc"}}}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col2", IsIndex: true, IsUnique: true, ConstraintName: getIndexName("table1", "i2"), Group: "i2", Order: 1, Sort: "asc"}}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, IsUnique: true, ConstraintName: getIndexName("table1", "i1"), Group: "i1", Order: 1, Sort: "asc"}}}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col2", IsIndex: true, IsUnique: true, ConstraintName: getIndexName("table1", "i1"), Group: "i1", Order: 2, Sort: "asc"}}}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{"DROP INDEX index__table1__i1 ON test.table1", "CREATE UNIQUE INDEX index__table1__i2 ON test.table1 (col2 asc, col1 asc)"},
			wantErr: false,
		},
		{
			name: "changing sort of unique index key ",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, IsUnique: true, ConstraintName: getIndexName("table1", "i1"), Group: "i1", Order: 2, Sort: "asc"}}}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col2", IsIndex: true, IsUnique: true, ConstraintName: getIndexName("table1", "i1"), Group: "i1", Order: 1, Sort: "desc"}}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, IsUnique: true, ConstraintName: getIndexName("table1", "i1"), Group: "i1", Order: 1, Sort: "desc"}}}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col2", IsIndex: true, IsUnique: true, ConstraintName: getIndexName("table1", "i1"), Group: "i1", Order: 2, Sort: "asc"}}}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{"DROP INDEX index__table1__i1 ON test.table1", "CREATE UNIQUE INDEX index__table1__i1 ON test.table1 (col2 desc, col1 asc)"},
			wantErr: false,
		},
		// 	Postgres
		{
			name: "adding unique directive to type Json",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeJSON, IsFieldTypeRequired: true, IndexInfo: []*model.TableProperties{{IsUnique: true}}}}}},
				currentSchema: model.Collection{},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{},
			wantErr: true,
		},
		{
			name: "adding unique key",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IsFieldTypeRequired: true, IndexInfo: []*model.TableProperties{{Field: "col1", IsUnique: true, IsIndex: true, Order: 1, Sort: "asc"}}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{"ALTER TABLE test.table1 ALTER COLUMN col1 SET NOT NULL", "CREATE UNIQUE INDEX index__table1__ ON test.table1 (col1 asc)"},
			wantErr: false,
		},
		{
			name: "adding unique index key to existing index",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, IsUnique: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 1, Sort: "asc"}}}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col2", IsIndex: true, IsUnique: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 2, Sort: "asc"}}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, IsUnique: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 1, Sort: "asc"}}}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{"ALTER TABLE test.table1 ADD COLUMN col2 integer", "DROP INDEX test.index__table1__i1", "CREATE UNIQUE INDEX index__table1__i1 ON test.table1 (col1 asc, col2 asc)"},
			wantErr: false,
		},
		{
			name: "adding new unique index key ",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, IsUnique: true, Group: "i1", Order: 1, Sort: "asc"}}}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col2", IsIndex: true, IsUnique: true, Group: "i2", Order: 1, Sort: "asc"}}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, IsUnique: true, Group: "i1", Order: 1, Sort: "asc"}}}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{"ALTER TABLE test.table1 ADD COLUMN col2 integer", "CREATE UNIQUE INDEX index__table1__i2 ON test.table1 (col2 asc)"},
			wantErr: false,
		},
		{
			name: "changing unique to index",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 1, Sort: "asc"}}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, IsUnique: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 1, Sort: "asc"}}}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{"DROP INDEX test.index__table1__i1", "CREATE INDEX index__table1__i1 ON test.table1 (col1 asc)"},
			wantErr: false,
		},
		{
			name: "changing order of unique index key ",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, IsUnique: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 2, Sort: "asc"}}}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col2", IsIndex: true, IsUnique: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 1, Sort: "asc"}}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, IsUnique: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 1, Sort: "asc"}}}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col2", IsIndex: true, IsUnique: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 2, Sort: "asc"}}}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{"DROP INDEX test.index__table1__i1", "CREATE UNIQUE INDEX index__table1__i1 ON test.table1 (col2 asc, col1 asc)"},
			wantErr: false,
		},
		{
			name: "changing sort of unique index key ",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, IsUnique: true, ConstraintName: getIndexName("table1", "i1"), Group: "i1", Order: 2, Sort: "asc"}}}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col2", IsIndex: true, IsUnique: true, ConstraintName: getIndexName("table1", "i1"), Group: "i1", Order: 1, Sort: "desc"}}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, IsUnique: true, ConstraintName: getIndexName("table1", "i1"), Group: "i1", Order: 1, Sort: "desc"}}}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col2", IsIndex: true, IsUnique: true, ConstraintName: getIndexName("table1", "i1"), Group: "i1", Order: 2, Sort: "asc"}}}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{"DROP INDEX test.index__table1__i1", "CREATE UNIQUE INDEX index__table1__i1 ON test.table1 (col2 desc, col1 asc)"},
			wantErr: false,
		},
		{
			name: "changing column type of single field unique index",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, IsUnique: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 1, Sort: "asc"}}}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col2", IsIndex: true, IsUnique: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 2, Sort: "desc"}}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeString, IndexInfo: []*model.TableProperties{{IsIndex: true, IsUnique: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 1, Sort: "desc"}}}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col2", IsIndex: true, IsUnique: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 2, Sort: "asc"}}}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{"DROP INDEX test.index__table1__i1", "ALTER TABLE test.table1 DROP COLUMN col1", "ALTER TABLE test.table1 ADD COLUMN col1 integer", "CREATE UNIQUE INDEX index__table1__i1 ON test.table1 (col1 asc, col2 desc)"},
			wantErr: false,
		},
		{
			name: "changing group of unique index key ",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, IsUnique: true, ConstraintName: getIndexName("table1", "i2"), Group: "i2", Order: 2, Sort: "asc"}}}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col2", IsIndex: true, IsUnique: true, ConstraintName: getIndexName("table1", "i2"), Group: "i2", Order: 1, Sort: "asc"}}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, IsUnique: true, ConstraintName: getIndexName("table1", "i1"), Group: "i1", Order: 1, Sort: "asc"}}}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col2", IsIndex: true, IsUnique: true, ConstraintName: getIndexName("table1", "i1"), Group: "i1", Order: 2, Sort: "asc"}}}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{"DROP INDEX test.index__table1__i1", "CREATE UNIQUE INDEX index__table1__i2 ON test.table1 (col2 asc, col1 asc)"},
			wantErr: false,
		},
	}
	var changingIndexKeyTestCases = []testGenerateCreationQueries{
		{
			name: "adding index directive to type Json",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeJSON, IsFieldTypeRequired: true, IndexInfo: []*model.TableProperties{{IsIndex: true}}}}}},
				currentSchema: model.Collection{},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{},
			wantErr: true,
		},
		{
			name: "adding index key",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IsFieldTypeRequired: true, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, Order: 1, Sort: "asc"}}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"ALTER TABLE table1 MODIFY col1 integer NOT NULL", "CREATE INDEX index__table1__ ON table1 (col1 asc)"},
			wantErr: false,
		},
		{
			name: "adding index key to existing index",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"id": &model.FieldType{FieldName: "id", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 1, Sort: "asc"}}}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col2", IsIndex: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 2, Sort: "asc"}}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"id": &model.FieldType{FieldName: "id", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 1, Sort: "asc"}}}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"ALTER TABLE table1 ADD col2 integer", "DROP INDEX index__table1__i1 ON table1", "CREATE INDEX index__table1__i1 ON table1 (col1 asc, col2 asc)"},
			wantErr: false,
		},
		{
			name: "adding new index key ",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, Group: "i1", Order: 1, Sort: "asc"}}}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col2", IsIndex: true, Group: "i2", Order: 1, Sort: "asc"}}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, Group: "i1", Order: 1, Sort: "asc"}}}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"ALTER TABLE table1 ADD col2 integer", "CREATE INDEX index__table1__i2 ON table1 (col2 asc)"},
			wantErr: false,
		},
		{
			name: "changing index to unique",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, IsUnique: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 1, Sort: "asc"}}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 1, Sort: "asc"}}}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"DROP INDEX index__table1__i1 ON table1", "CREATE UNIQUE INDEX index__table1__i1 ON table1 (col1 asc)"},
			wantErr: false,
		},
		{
			name: "changing order of index key ",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 2, Sort: "asc"}}}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col2", IsIndex: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 1, Sort: "asc"}}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 1, Sort: "asc"}}}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col2", IsIndex: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 2, Sort: "asc"}}}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"DROP INDEX index__table1__i1 ON table1", "CREATE INDEX index__table1__i1 ON table1 (col2 asc, col1 asc)"},
			wantErr: false,
		},
		{
			name: "changing qroup of index key ",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, Group: "i2", ConstraintName: getIndexName("table1", "i2"), Order: 2, Sort: "asc"}}}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col2", IsIndex: true, Group: "i2", ConstraintName: getIndexName("table1", "i2"), Order: 1, Sort: "asc"}}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 1, Sort: "asc"}}}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col2", IsIndex: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 2}}}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"DROP INDEX index__table1__i1 ON table1", "CREATE INDEX index__table1__i2 ON table1 (col2 asc, col1 asc)"},
			wantErr: false,
		},
		{
			name: "changing sort of index key ",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, ConstraintName: getIndexName("table1", "i1"), Group: "i1", Order: 1, Sort: "asc"}}}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col2", IsIndex: true, ConstraintName: getIndexName("table1", "i1"), Group: "i1", Order: 2, Sort: "asc"}}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, ConstraintName: getIndexName("table1", "i1"), Group: "i1", Order: 1, Sort: "desc"}}}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col2", IsIndex: true, ConstraintName: getIndexName("table1", "i1"), Group: "i1", Order: 2, Sort: "desc"}}}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"DROP INDEX index__table1__i1 ON table1", "CREATE INDEX index__table1__i1 ON table1 (col1 asc, col2 asc)"},
			wantErr: false,
		},
		{
			name: "adding invalid order key",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IsFieldTypeRequired: true, IndexInfo: []*model.TableProperties{{IsIndex: true, Order: 2}}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			wantErr: true,
		},
		// 	Sql server
		{
			name: "sqlserver: adding two columns",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IsFieldTypeRequired: true, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, Order: 1, Sort: "asc"}}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger}}},
			},
			isSort:  true,
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{"ALTER TABLE test.table1 ALTER COLUMN col1 integer NOT NULL", "CREATE INDEX index__table1__ ON test.table1 (col1 asc)"},
			wantErr: false,
		},
		{
			name: "adding index key to existing index",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 1, Sort: "asc"}}}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col2", IsIndex: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 2, Sort: "asc"}}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 1, Sort: "asc"}}}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{"ALTER TABLE test.table1 ADD col2 integer", "DROP INDEX index__table1__i1 ON test.table1", "CREATE INDEX index__table1__i1 ON test.table1 (col1 asc, col2 asc)"},
			wantErr: false,
		},
		{
			name: "adding new index key ",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, Group: "i1", Order: 1, Sort: "asc"}}}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col2", IsIndex: true, Group: "i2", Order: 1, Sort: "asc"}}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, Group: "i1", Order: 1, Sort: "asc"}}}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{"ALTER TABLE test.table1 ADD col2 integer", "CREATE INDEX index__table1__i2 ON test.table1 (col2 asc)"},
			wantErr: false,
		},
		{
			name: "changing order of index key ",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 2, Sort: "asc"}}}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col2", IsIndex: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 1, Sort: "asc"}}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 1, Sort: "asc"}}}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col2", IsIndex: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 2, Sort: "asc"}}}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{"DROP INDEX index__table1__i1 ON test.table1", "CREATE INDEX index__table1__i1 ON test.table1 (col2 asc, col1 asc)"},
			wantErr: false,
		},
		{
			name: "changing qroup of index key ",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, ConstraintName: getIndexName("table1", "i2"), Group: "i2", Order: 2, Sort: "asc"}}}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col2", IsIndex: true, ConstraintName: getIndexName("table1", "i2"), Group: "i2", Order: 1, Sort: "asc"}}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, ConstraintName: getIndexName("table1", "i1"), Group: "i1", Order: 1, Sort: "asc"}}}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col2", IsIndex: true, ConstraintName: getIndexName("table1", "i1"), Group: "i1", Order: 2}}}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{"DROP INDEX index__table1__i1 ON test.table1", "CREATE INDEX index__table1__i2 ON test.table1 (col2 asc, col1 asc)"},
			wantErr: false,
		},
		{
			name: "changing sort of index key ",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, ConstraintName: getIndexName("table1", "i1"), Group: "i1", Order: 1, Sort: "asc"}}}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col2", IsIndex: true, ConstraintName: getIndexName("table1", "i1"), Group: "i1", Order: 2, Sort: "asc"}}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, ConstraintName: getIndexName("table1", "i1"), Group: "i1", Order: 1, Sort: "desc"}}}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col2", IsIndex: true, ConstraintName: getIndexName("table1", "i1"), Group: "i1", Order: 2, Sort: "desc"}}}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{"DROP INDEX index__table1__i1 ON test.table1", "CREATE INDEX index__table1__i1 ON test.table1 (col1 asc, col2 asc)"},
			wantErr: false,
		},
		{
			name: "adding invalid order key",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IsFieldTypeRequired: true, IndexInfo: []*model.TableProperties{{IsIndex: true, Order: 2}}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			wantErr: true,
		},
		// 	Postgres
		{
			name: "adding index key",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IsFieldTypeRequired: true, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, Order: 1, Sort: "asc"}}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{"ALTER TABLE test.table1 ALTER COLUMN col1 SET NOT NULL", "CREATE INDEX index__table1__ ON test.table1 (col1 asc)"},
			wantErr: false,
		},
		{
			name: "adding index key to existing index",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 1, Sort: "asc"}}}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col2", IsIndex: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 2, Sort: "asc"}}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 1, Sort: "asc"}}}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{"ALTER TABLE test.table1 ADD COLUMN col2 integer", "DROP INDEX test.index__table1__i1", "CREATE INDEX index__table1__i1 ON test.table1 (col1 asc, col2 asc)"},
			wantErr: false,
		},
		{
			name: "adding new index key ",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, Group: "i1", Order: 1, Sort: "asc"}}}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col2", IsIndex: true, Group: "i2", Order: 1, Sort: "asc"}}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, Group: "i1", Order: 1, Sort: "asc"}}}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{"ALTER TABLE test.table1 ADD COLUMN col2 integer", "CREATE INDEX index__table1__i2 ON test.table1 (col2 asc)"},
			wantErr: false,
		},
		{
			name: "changing index to unique",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, IsUnique: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 1, Sort: "asc"}}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 1, Sort: "asc"}}}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{"DROP INDEX test.index__table1__i1", "CREATE UNIQUE INDEX index__table1__i1 ON test.table1 (col1 asc)"},
			wantErr: false,
		},
		{
			name: "changing index to unique",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, IsUnique: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 1, Sort: "asc"}}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 1, Sort: "asc"}}}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{"DROP INDEX test.index__table1__i1", "CREATE UNIQUE INDEX index__table1__i1 ON test.table1 (col1 asc)"},
			wantErr: false,
		},

		{
			name: "changing order of index key ",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 2, Sort: "asc"}}}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col2", IsIndex: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 1, Sort: "asc"}}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 1, Sort: "asc"}}}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col2", IsIndex: true, Group: "i1", ConstraintName: getIndexName("table1", "i1"), Order: 2, Sort: "asc"}}}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{"DROP INDEX test.index__table1__i1", "CREATE INDEX index__table1__i1 ON test.table1 (col2 asc, col1 asc)"},
			wantErr: false,
		},
		{
			name: "changing qroup of index key ",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, ConstraintName: getIndexName("table1", "i2"), Group: "i2", Order: 2, Sort: "asc"}}}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col2", IsIndex: true, ConstraintName: getIndexName("table1", "i2"), Group: "i2", Order: 1, Sort: "asc"}}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, ConstraintName: getIndexName("table1", "i1"), Group: "i1", Order: 1, Sort: "asc"}}}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col2", ConstraintName: getIndexName("table1", "i1"), Group: "i1", Order: 2, IsIndex: true}}}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{"DROP INDEX test.index__table1__i1", "CREATE INDEX index__table1__i2 ON test.table1 (col2 asc, col1 asc)"},
			wantErr: false,
		},
		{
			name: "changing sort of index key",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, ConstraintName: getIndexName("table1", "i1"), Group: "i1", Order: 1, Sort: "asc"}}}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col2", IsIndex: true, ConstraintName: getIndexName("table1", "i1"), Group: "i1", Order: 2, Sort: "asc"}}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col1", IsIndex: true, ConstraintName: getIndexName("table1", "i1"), Group: "i1", Order: 1, Sort: "desc"}}}, "col2": &model.FieldType{FieldName: "col2", Kind: model.TypeInteger, IndexInfo: []*model.TableProperties{{Field: "col2", IsIndex: true, ConstraintName: getIndexName("table1", "i1"), Group: "i1", Order: 2, Sort: "desc"}}}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{"DROP INDEX test.index__table1__i1", "CREATE INDEX index__table1__i1 ON test.table1 (col1 asc, col2 asc)"},
			wantErr: false,
		},
		{
			name: "adding invalid order key",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger, IsFieldTypeRequired: true, IndexInfo: []*model.TableProperties{{IsIndex: true, Order: 2}}}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeInteger}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			wantErr: true,
		},
		{
			name: "adding index directive to type Json",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeJSON, IsFieldTypeRequired: true, IndexInfo: []*model.TableProperties{{IsIndex: true}}}}}},
				currentSchema: model.Collection{},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{},
			wantErr: true,
		},
	}
	var miscellaneousTestCases = []testGenerateCreationQueries{
		// 	Mysql
		{
			name: "Wrong dbAlias",
			args: args{
				dbAlias:       "wrgDbAlias",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{}}},
				currentSchema: model.Collection{"table1": model.Fields{}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			wantErr: true,
		},
		{
			name: "when table is not provided",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{}},
				currentSchema: model.Collection{},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			wantErr: false,
		},
		{
			name: "tablename  present in currentschema but not in realschema",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table2": model.Fields{"col1": &model.FieldType{FieldName: "col1", TypeIDSize: model.DefaultCharacterSize, Kind: model.TypeID}}}},
				currentSchema: model.Collection{"table2": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeString}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			wantErr: true,
		},
		{
			name: "tablename  not present in currentschema, realschema",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table2": model.Fields{"col1": &model.FieldType{FieldName: "col1", TypeIDSize: model.DefaultCharacterSize, Kind: model.TypeID}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeString}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			wantErr: false,
		},
		{
			name: "tablename  present in realschema but not in realschema",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"id": &model.FieldType{FieldName: "id", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col1": &model.FieldType{FieldName: "col1", TypeIDSize: model.DefaultCharacterSize, Kind: model.TypeID}}}},
				currentSchema: model.Collection{"table2": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeString}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			want:    []string{"CREATE TABLE table1 (id varchar(100) NOT NULL , col1 varchar(100) ,PRIMARY KEY (id));"},
			wantErr: false,
		},
		{
			name: "fieldtype of type object in realschema",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeObject}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeString}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			wantErr: true,
		},
		{
			name: "invalid fieldtype in realschema and table not present in current schema",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeObject}}}},
				currentSchema: model.Collection{"table2": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeString}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			wantErr: true,
		},
		{
			name: "invalid fieldtype in realschema",
			args: args{
				dbAlias:       "mysql",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"mysql": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: "int"}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeObject}}},
			},
			fields:  fields{crud: crudMySQL, project: "test"},
			wantErr: true,
		},
		// 	SQL server
		{
			name: "Wrong dbAlias",
			args: args{
				dbAlias:       "wrgDbAlias",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{}}},
				currentSchema: model.Collection{"table1": model.Fields{}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			wantErr: true,
		},
		{
			name: "when table is not provided",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{}},
				currentSchema: model.Collection{},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			wantErr: false,
		},
		{
			name: "tablename  present in currentschema but not in realschema",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table2": model.Fields{"id": &model.FieldType{FieldName: "id", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col1": &model.FieldType{FieldName: "col1", TypeIDSize: model.DefaultCharacterSize, Kind: model.TypeID}}}},
				currentSchema: model.Collection{"table2": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeString}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			wantErr: true,
		},
		{
			name: "tablename  not present in currentschema, realschema",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table2": model.Fields{"col1": &model.FieldType{FieldName: "col1", TypeIDSize: model.DefaultCharacterSize, Kind: model.TypeID}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeString}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			wantErr: false,
		},
		{
			name: "tablename  present in realschema but not in realschema",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"id": &model.FieldType{FieldName: "id", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col1": &model.FieldType{FieldName: "col1", TypeIDSize: model.DefaultCharacterSize, Kind: model.TypeID}}}},
				currentSchema: model.Collection{"table2": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeString}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			want:    []string{"CREATE TABLE test.table1 (id nvarchar(100) NOT NULL , col1 nvarchar(100) ,PRIMARY KEY (id));"},
			wantErr: false,
		},
		{
			name: "fieldtype of type object in realschema",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeObject}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeString}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			wantErr: true,
		},
		{
			name: "invalid fieldtype in realschema and table not present in current schema",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeObject}}}},
				currentSchema: model.Collection{"table2": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeString}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			wantErr: true,
		},
		{
			name: "invalid fieldtype in realschema",
			args: args{
				dbAlias:       "sqlserver",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"sqlserver": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: "int"}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeObject}}},
			},
			fields:  fields{crud: crudSQLServer, project: "test"},
			wantErr: true,
		},
		{
			name: "Wrong dbAlias",
			args: args{
				dbAlias:       "wrgDbAlias",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{}}},
				currentSchema: model.Collection{"table1": model.Fields{}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			wantErr: true,
		},
		{
			name: "when table is not provided",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{}},
				currentSchema: model.Collection{},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			wantErr: false,
		},
		{
			name: "tablename  present in currentschema but not in realschema",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table2": model.Fields{"col1": &model.FieldType{FieldName: "col1", TypeIDSize: model.DefaultCharacterSize, Kind: model.TypeID}}}},
				currentSchema: model.Collection{"table2": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeString}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			wantErr: true,
		},
		{
			name: "tablename  not present in currentschema, realschema",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table2": model.Fields{"col1": &model.FieldType{FieldName: "col1", TypeIDSize: model.DefaultCharacterSize, Kind: model.TypeID}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeString}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			wantErr: false,
		},
		{
			name: "tablename  present in realschema but not in realschema",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"id": &model.FieldType{FieldName: "id", Kind: model.TypeID, TypeIDSize: model.DefaultCharacterSize, IsPrimary: true, PrimaryKeyInfo: &model.TableProperties{}, IsFieldTypeRequired: true}, "col1": &model.FieldType{FieldName: "col1", TypeIDSize: model.DefaultCharacterSize, Kind: model.TypeID}}}},
				currentSchema: model.Collection{"table2": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeString}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			want:    []string{"CREATE TABLE test.table1 (id character varying(100) NOT NULL , col1 character varying(100) ,PRIMARY KEY (id));"},
			wantErr: false,
		},
		{
			name: "fieldtype of type object in realschema",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeObject}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeString}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			wantErr: true,
		},
		{
			name: "invalid fieldtype in realschema and table not present in current schema",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgres": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeObject}}}},
				currentSchema: model.Collection{"table2": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeString}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			wantErr: true,
		},
		{
			name: "invalid fieldtype in realschema",
			args: args{
				dbAlias:       "postgres",
				tableName:     "table1",
				project:       "test",
				parsedSchema:  model.Type{"postgress": model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: "int"}}}},
				currentSchema: model.Collection{"table1": model.Fields{"col1": &model.FieldType{FieldName: "col1", Kind: model.TypeObject}}},
			},
			fields:  fields{crud: crudPostgres, project: "test"},
			wantErr: false,
		},
	}

	testCases := make([]testGenerateCreationQueries, 0)
	testCases = append(testCases, noQueriesGeneratedTestCases...)
	testCases = append(testCases, createTableTestCases...)
	testCases = append(testCases, dropColumTestCases...)
	testCases = append(testCases, changingNotNullOfColumnTestCases...)
	testCases = append(testCases, changingTypeOfColumnTestCases...)
	testCases = append(testCases, changingPrimaryKeyTestCases...)
	testCases = append(testCases, changingLinkTestCases...)
	testCases = append(testCases, changingForeignKeyTestCases...)
	testCases = append(testCases, changingUniqueIndexKeyTestCases...)
	testCases = append(testCases, changingIndexKeyTestCases...)
	testCases = append(testCases, miscellaneousTestCases...)

	for _, tt := range testCases {
		t.Run(tt.name, func(t *testing.T) {
			s := &Schema{
				SchemaDoc: tt.fields.SchemaDoc,
				crud:      tt.fields.crud,
				project:   tt.fields.project,
				dbSchemas: tt.fields.config,
			}
			got, err := s.generateCreationQueries(context.Background(), tt.args.dbAlias, tt.args.tableName, tt.args.project, tt.args.parsedSchema, tt.args.currentSchema)
			if (err != nil) != tt.wantErr {
				t.Errorf("dbAlias : %v name = %v, Schema.generateCreationQueries()\n error = %v,\n wantErr %v", tt.args.dbAlias, tt.name, err, tt.wantErr)
				return
			}

			if !tt.wantErr {
				if len(got) != len(tt.want) {
					t.Errorf("dbAlias : %v Schema.generateCreationQueries() length error:\n got = %v,\n want = %v", tt.args.dbAlias, got, tt.want)
					return
				}
				if tt.isSort {
					got = sortArray(got)
					tt.want = sortArray(tt.want)
				}
				for i, v := range got {
					if tt.want[i] != v {
						t.Errorf("dbAlias : %v Schema.generateCreationQueries()\n got = %v,\n want %v", tt.args.dbAlias, got, tt.want)
						return
					}
				}
			}
		})
	}
}

func sortArray(a []string) []string {
	l := len(a)
	for i := 0; i < l; i++ {
		for j := i; j < l; j++ {
			if a[i] > a[j] {
				a[i], a[j] = a[j], a[i]
			}
		}
	}
	return a
}
